diff --git a/README.md b/README.md
index deb3c21..b5f036a 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Available from Maven Central:
com.x5dev
chunk-templates
- 3.1.3
+ 3.2.0
```
diff --git a/pom.xml b/pom.xml
index 050adcf..2dd1d5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
com.x5dev
chunk-templates
jar
- 3.1.3
+ 3.2.0
Chunk Templates
Chunk Template Engine for Java
http://www.x5software.com/chunk/
diff --git a/src/main/java/com/x5/template/Chunk.java b/src/main/java/com/x5/template/Chunk.java
index e51ee80..1023dee 100644
--- a/src/main/java/com/x5/template/Chunk.java
+++ b/src/main/java/com/x5/template/Chunk.java
@@ -243,7 +243,7 @@
* Updates: Chunk Documentation
*
* @author Tom McClure
- * @version 3.1.3
+ * @version 3.2.0
*/
public class Chunk implements Map
@@ -251,7 +251,7 @@ public class Chunk implements Map
public static final int HASH_THRESH = 8;
public static final int DEPTH_LIMIT = 17;
- public static final String VERSION = "3.1.3";
+ public static final String VERSION = "3.2.0";
private static final String TRUE = "TRUE";
diff --git a/src/main/java/com/x5/template/Theme.java b/src/main/java/com/x5/template/Theme.java
index cb3a042..bc89e6a 100644
--- a/src/main/java/com/x5/template/Theme.java
+++ b/src/main/java/com/x5/template/Theme.java
@@ -50,6 +50,11 @@ public Theme(ThemeConfig config)
if (encoding != null) {
this.setEncoding(encoding);
}
+
+ String themeResourcePath = config.getThemeResourcePath();
+ if (themeResourcePath != null) {
+ this.setClasspathThemesFolder(themeResourcePath);
+ }
}
public Theme(ContentSource templates)
@@ -74,14 +79,19 @@ public Theme(String themesFolder, String themeLayerNames, String ext)
this.fileExtension = ext;
}
- public void setClasspathThemesFolder(String classpathThemesFolder) {
- this.classpathThemesFolder = classpathThemesFolder;
+ public void setClasspathThemesFolder(String classpathThemesFolder)
+ {
+ if (this.themeLayers.size() > 0) {
+ throw new java.lang.IllegalStateException("Must specify paths before lazy init.");
+ } else {
+ this.classpathThemesFolder = classpathThemesFolder;
+ }
}
public void setTemplateFolder(String pathToTemplates)
{
if (this.themeLayers.size() > 0) {
- throw new java.lang.IllegalStateException("Must specify extension before lazy init.");
+ throw new java.lang.IllegalStateException("Must specify paths before lazy init.");
} else {
this.themesFolder = pathToTemplates;
}
diff --git a/src/main/java/com/x5/template/ThemeConfig.java b/src/main/java/com/x5/template/ThemeConfig.java
index 29275b9..ba3c289 100644
--- a/src/main/java/com/x5/template/ThemeConfig.java
+++ b/src/main/java/com/x5/template/ThemeConfig.java
@@ -13,6 +13,7 @@
public class ThemeConfig
{
public static final String THEME_PATH = "theme_path";
+ public static final String THEME_RESOURCE_PATH = "theme_resource_path";
public static final String LAYER_NAMES = "layers";
public static final String DEFAULT_EXT = "default_extension";
public static final String CACHE_MINUTES = "cache_minutes";
@@ -26,6 +27,7 @@ public class ThemeConfig
public static final String STANDARD_DEFAULT_EXT = "chtml";
private String themePath = null;
+ private String themeResourcePath = null;
private String layerNames = null;
private String defaultExtension = STANDARD_DEFAULT_EXT;
private int cacheMinutes = 0;
@@ -51,6 +53,8 @@ public void set(String configKey, String value)
if (configKey.equals(THEME_PATH)) {
this.themePath = value;
+ } else if (configKey.equals(THEME_RESOURCE_PATH)) {
+ this.themeResourcePath = value;
} else if (configKey.equals(LAYER_NAMES)) {
this.layerNames = value;
} else if (configKey.equals(DEFAULT_EXT)) {
@@ -169,6 +173,11 @@ public String getThemeFolder()
return this.themePath;
}
+ public String getThemeResourcePath()
+ {
+ return this.themeResourcePath;
+ }
+
public String getLayerNames()
{
return this.layerNames;
diff --git a/src/main/java/com/x5/util/Path.java b/src/main/java/com/x5/util/Path.java
index ea2757c..f3051d2 100644
--- a/src/main/java/com/x5/util/Path.java
+++ b/src/main/java/com/x5/util/Path.java
@@ -1,7 +1,9 @@
package com.x5.util;
-public class Path {
- public static String ensureTrailingSeparator(String path) {
+public class Path
+{
+ public static String ensureTrailingSeparator(String path)
+ {
if (path != null) {
char lastChar = path.charAt(path.length()-1);
char fs = System.getProperty("file.separator").charAt(0);
diff --git a/src/test/java/com/x5/template/ConfigTest.java b/src/test/java/com/x5/template/ConfigTest.java
index 87e9336..38aeee8 100644
--- a/src/test/java/com/x5/template/ConfigTest.java
+++ b/src/test/java/com/x5/template/ConfigTest.java
@@ -61,6 +61,19 @@ public void testUserFilterConfig()
assertEquals("XXXspacey XXX", c.toString());
}
+ @Test
+ public void testAlternateResourcePath()
+ {
+ Map cfg = new HashMap();
+ cfg.put("theme_resource_path", "/alt/themes");
+
+ ThemeConfig config = new ThemeConfig(cfg);
+ Theme theme = new Theme(config);
+ Chunk c = theme.makeChunk("hello#hello_world");
+ c.set("what_kind", "bizarro");
+ assertEquals("Hello bizarro world!", c.toString());
+ }
+
@Test
public void testHideErrors()
{
diff --git a/src/test/resources/alt/themes/hello.chtml b/src/test/resources/alt/themes/hello.chtml
new file mode 100644
index 0000000..0c54f3b
--- /dev/null
+++ b/src/test/resources/alt/themes/hello.chtml
@@ -0,0 +1 @@
+{#hello_world}Hello {$what_kind:chunky} world!{#}