Skip to content

Commit

Permalink
Initial 0.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McClure committed Dec 16, 2016
1 parent dff0dd1 commit c7a3c64
Show file tree
Hide file tree
Showing 3 changed files with 418 additions and 0 deletions.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
# chunk-springmvc
Chunk Templates for Spring MVC

Facilitates swapping in the Chunk Template engine for Spring MVC projects
in place of jsp or another template engine.

### Quick start:

Add the following to your dispatcher-servlet.xml:
```
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="com.x5.template.spring.ChunkTemplateView"/>
<property name="prefix" value="/WEB-INF/chunk/"/>
<property name="suffix" value=".chtml"/>
<property name="requestContextAttribute" value="rc"/>
</bean>
<bean id="chunkTemplatesConfig" class="java.util.HashMap" scope="prototype">
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="default_extension" value="chtml" />
<entry key="cache_minutes" value="0" />
<entry key="layers" value="" />
<entry key="theme_path" value="" />
<entry key="hide_errors" value="FALSE" />
<entry key="error_log" value="" />
<entry key="encoding" value="UTF-8" />
<entry key="locale" value="" />
<entry key="filters" value="" />
</map>
</constructor-arg>
</bean>
```

Complete project setup guide here:
http://www.x5software.com/chunk/wiki/Spring_MVC

### Notes

MVC Framework localized messages (defined in messages.properties etc)
are available via a custom tag command:
```
{% messages.msg.name %}
```

Messages can be parameterized like so: ``{% messages.msg.name(`$a`,`$b`) %}``

A special request context tag is available, usually {$rc} but the name is
configurable.

The following request context values are available:
```
{$rc.uri}
{$rc.context_path}
{$rc.servlet_path}
{$rc.scheme}
{$rc.method}
{$rc.server_name}
{$rc.remote_addr}
{$rc.remote_host}
{$rc.remote_user}
```

### Using bean getters in a template

When exposing beans (or POJO member variables) in a model, keep in mind that
Chunk always converts ``camelCase`` to ``snake_case``.

So, ``x.getFavoriteColor()`` will be available in the template as
``{% $x.favorite_color %}`` -- and ``x.isBigAndHairy()`` must be checked
like so:
```
{% if $x.big_and_hairy %}...{% endif %}
```
171 changes: 171 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.x5dev</groupId>
<artifactId>chunk-springmvc</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<name>Chunk Templates for Spring MVC</name>
<description>Chunk Templates plugin for Spring MVC framework</description>
<url>http://www.x5software.com/chunk/wiki/Spring_MVC</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>scm:git:git@github.com:tomj74/chunk-springmvc.git</url>
<connection>scm:git:git@github.com:tomj74/chunk-springmvc.git</connection>
<developerConnection>scm:git:git@github.com:tomj74/chunk-springmvc.git</developerConnection>
</scm>

<dependencies>
<dependency>
<groupId>com.x5dev</groupId>
<artifactId>chunk-templates</artifactId>
<version>[3.2.4,4.0.0)</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.5.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.5.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.5.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>

<developers>
<developer>
<id>goredsoxgo</id>
<name>Tom McClure</name>
<email>tom@dagblastit.com</email>
<url>http://www.dagblastit.com/</url>
<organization>X5 Software</organization>
<organizationUrl>http://www.x5software.com/</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>-8</timezone>
<properties>
<picUrl>http://tinyurl.com/TomMcClureAvatar</picUrl>
</properties>
</developer>
</developers>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Loading

0 comments on commit c7a3c64

Please sign in to comment.