Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
freemarker template engine plugin for vraptor
Java

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.settings
src/main
.gitignore
LICENSE
README-pt-br.markdown
README.markdown
pom.xml

README.markdown

vraptor-freemarker

A simple freemarker engine for rendering templates from within jar files, or rendering email etc.

installing

Vraptor-freemarker.jar can be downloaded from maven's repository, or configured in any compatible tool:

    <dependency>
        <groupId>br.com.caelum.vraptor</groupId>
        <artifactId>vraptor-freemarker</artifactId>
        <version>1.1.0</version>
        <scope>compile</scope>
    </dependency>

usage for rendering pages

    @Resource
    public class DashboardController {

        private final User user;
        private final Freemarker freemarker;

        public DashboardController(User user, Freemarker freemarker) {
            this.user = user;
            this.freemarker = freemarker;
        }

        @Path("/admin/dashboard")
        @Get
        public void list() throws IOException, TemplateException {
            freemarker.use("dashboard").with("currentUser", user).render();
        }

    }

or...

    @Resource
    public class DashboardController {

        private final User user;
        private final Result result;

        public DashboardController(User user, Result result) {
            this.user = user;
            this.result = result;
        }

        @Path("/admin/dashboard")
        @Get
        public void list() throws IOException, TemplateException {
            result.include("currentUser", user);
            result.use(FreemarkerView.class).withTemplate("dashboard");
        }

    }

usage for rendering emails

    String body = freemarker.use("send_mail_notification").with("currentUser", user).getContent();

usage when testing

    @Test
    public void testSomething() throws Exception {
        new DashboardController(new User(), new MockFreemarker()).list();
        // your assertions here
    }

help

Get help from vraptor developers and the community at vraptor mailing list.

Something went wrong with that request. Please try again.