java spring framework mvc view for Mustache.js templates
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Mustache.js View for Spring Web MVC

Supports both jmustache and mustache.java

Build Status Coverage Status

Maven Dependency

<dependency>
    <groupId>com.github.sps.mustache</groupId>
    <artifactId>mustache-spring-view</artifactId>
    <version>1.3</version>
</dependency>

<!-- jmustache -->
<dependency>
    <groupId>com.samskivert</groupId>
    <artifactId>jmustache</artifactId>
    <version>${jmustache.version}</version>
</dependency>

<!-- mustache.java -->
<dependency>
	<groupId>com.github.spullara.mustache.java</groupId>
    <artifactId>compiler</artifactId>
    <version>${mustache.java.version}</version>
</dependency>

Spring Configuration

<!-- jmustache -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.mustache.MustacheViewResolver">
    <property name="suffix" value=""/>
    <property name="cache" value="${TEMPLATE_CACHE_ENABLED}" />
    <property name="templateFactory">
        <bean class="org.springframework.web.servlet.view.mustache.jmustache.JMustacheTemplateFactory">
            <property name="escapeHTML" value="true"/>
            <property name="standardsMode" value="false"/>
            <property name="templateLoader">
                <bean class="org.springframework.web.servlet.view.mustache.jmustache.JMustacheTemplateLoader"/>                                
            </property>
        </bean>
    </property>
</bean>

<!-- mustache.java -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.mustache.MustacheViewResolver">
    <property name="suffix" value=""/>
    <property name="cache" value="${TEMPLATE_CACHE_ENABLED}"/>
    <property name="templateFactory">
        <bean class="org.springframework.web.servlet.view.mustache.java.MustacheJTemplateFactory" />
    </property>
</bean>

Localization Support

<bean id="messageSource" .../>

<!-- using mustache.java -->
<bean id="i18nMessageInterceptor"
      class="org.springframework.web.servlet.view.mustache.java.LocalizationMessageInterceptor">
    <property name="localeResolver" ref="..." />
</bean>

<!-- using jmustache -->
<bean id="i18nMessageInterceptor" class="org.springframework.web.servlet.view.mustache.jmustache.LocalizationMessageInterceptor">
    <property name="localeResolver" ref="..." />
</bean>

Thanks

Thanks to Eric White for forking this code base and providing the mustache.java implementation.