Skip to content

Commit

Permalink
v4: set/use handlebarsjs-v4.0.4 fixes #443
Browse files Browse the repository at this point in the history
  • Loading branch information
jknack committed Nov 8, 2015
1 parent 32af2bf commit 749f867
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 4,220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public class PrecompilePlugin extends HandlebarsPlugin {
/**
* The handlebars js file.
*/
@Parameter(defaultValue = "/handlebars-v3.0.3.js")
@Parameter(defaultValue = "/handlebars-v4.0.4.js")
private String handlebarsJsFile;

/**
Expand Down Expand Up @@ -442,7 +442,7 @@ public void addTemplate(final String template) {
* .handlebarsJsFile("handlebars-v1.3.0.js");
* </pre>
*
* Default handlebars.js is <code>handlebars-v3.0.3.js</code>.
* Default handlebars.js is <code>handlebars-v4.0.4.js</code>.
*
* @param handlebarsJsFile A classpath location of the handlebar.js file.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void withAmdOutput() throws Exception {
plugin.addTemplate("c");
plugin.setAmd(true);
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void i18nJs() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/helpers-i18njs.js");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();

Expand All @@ -44,7 +44,7 @@ public void chooseSpecificFiles() throws Exception {
plugin.addTemplate("a");
plugin.addTemplate("c");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();

Expand All @@ -59,7 +59,7 @@ public void outputDirMustBeCreated() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/newdir/helpers.js");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();
}
Expand All @@ -71,7 +71,7 @@ public void missingHelperMustBeSilent() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/missing-helpers.js");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();
}
Expand All @@ -83,7 +83,7 @@ public void noFileMustBeCreatedIfNoTemplatesWereFound() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/no-helpers.js");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();

Expand Down Expand Up @@ -125,7 +125,7 @@ public void mustFailOnUnExpectedException() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/no-helpers.js");
plugin.setProject(project);
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();
}
Expand All @@ -137,7 +137,7 @@ public void fileWithRuntimeMustBeLargerThanNormalFiles() throws Exception {
withoutRT.setSuffix(".html");
withoutRT.setOutput("target/without-rt-helpers.js");
withoutRT.setProject(newProject());
withoutRT.setHandlebarsJsFile("/handlebars-v3.0.3.js");
withoutRT.setHandlebarsJsFile("/handlebars-v4.0.4.js");

withoutRT.execute();

Expand All @@ -147,7 +147,7 @@ public void fileWithRuntimeMustBeLargerThanNormalFiles() throws Exception {
withRT.setOutput("target/with-rt-helpers.js");
withRT.setRuntime("src/test/resources/handlebars.runtime.js");
withRT.setProject(newProject());
withRT.setHandlebarsJsFile("/handlebars-v3.0.3.js");
withRT.setHandlebarsJsFile("/handlebars-v4.0.4.js");

withRT.execute();

Expand All @@ -163,7 +163,7 @@ public void normalFileShouleBeLargerThanMinimizedFiles() throws Exception {
withoutRT.setSuffix(".html");
withoutRT.setOutput("target/helpers-normal.js");
withoutRT.setProject(newProject());
withoutRT.setHandlebarsJsFile("/handlebars-v3.0.3.js");
withoutRT.setHandlebarsJsFile("/handlebars-v4.0.4.js");

withoutRT.execute();

Expand All @@ -173,7 +173,7 @@ public void normalFileShouleBeLargerThanMinimizedFiles() throws Exception {
withRT.setOutput("target/helpers.min.js");
withRT.setMinimize(true);
withRT.setProject(newProject());
withRT.setHandlebarsJsFile("/handlebars-v3.0.3.js");
withRT.setHandlebarsJsFile("/handlebars-v4.0.4.js");
withRT.execute();

assertTrue("Normal file must be larger than minimized",
Expand All @@ -188,7 +188,7 @@ public void partials() throws Exception {
plugin.setSuffix(".html");
plugin.setOutput("target/helpers.js");
plugin.setProject(newProject());
plugin.setHandlebarsJsFile("/handlebars-v3.0.3.js");
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");

plugin.execute();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(function () {
// Source: src/test/resources/i18nJs/i18njs.html

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;

return this.escapeExpression(((helper = (helper = helpers.i18nJs || (depth0 != null ? depth0.i18nJs : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"i18nJs","hash":{},"data":data}) : helper)))
return container.escapeExpression(((helper = (helper = helpers.i18nJs || (depth0 != null ? depth0.i18nJs : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"i18nJs","hash":{},"data":data}) : helper)))
+ "\n"
+ this.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0,"hello",{"name":"i18n","hash":{},"data":data}))
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"hello",{"name":"i18n","hash":{},"data":data}))
+ "\n"
+ this.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0,"formatted","Edgar!",{"name":"i18n","hash":{},"data":data}))
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"formatted","Edgar!",{"name":"i18n","hash":{},"data":data}))
+ "\n"
+ this.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0,"args","a","b","c",{"name":"i18n","hash":{},"data":data}))
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"args","a","b","c",{"name":"i18n","hash":{},"data":data}))
+ "\n";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand Down
14 changes: 7 additions & 7 deletions handlebars-maven-plugin/src/test/resources/helpers.expected
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(function () {
// Source: src/test/resources/partials/level1/level1.html

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;

return "<h1>I'm "
+ this.escapeExpression(((helper = (helper = helpers.level1 || (depth0 != null ? depth0.level1 : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"level1","hash":{},"data":data}) : helper)))
+ container.escapeExpression(((helper = (helper = helpers.level1 || (depth0 != null ? depth0.level1 : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"level1","hash":{},"data":data}) : helper)))
+ "</h1>";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand All @@ -16,11 +16,11 @@

// Source: src/test/resources/partials/partial/base.html

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;

return "I'm the base partial\n"
+ ((stack1 = this.invokePartial(partials['partial/partial'],depth0,{"name":"partial/partial","data":data,"helpers":helpers,"partials":partials})) != null ? stack1 : "");
+ ((stack1 = container.invokePartial(partials["partial/partial"],depth0,{"name":"partial/partial","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"usePartial":true,"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
templates['partial/base'] = template;
Expand All @@ -30,7 +30,7 @@

// Source: src/test/resources/partials/partial/partial.html

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "I'm the child partial";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand All @@ -41,9 +41,9 @@

// Source: src/test/resources/partials/root.html

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "Hello "
+ this.escapeExpression(this.lambda(depth0, depth0))
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "!";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Source: src/test/resources/templates/a.hbs
define('a.hbs', ['handlebars'], function(Handlebars) {
var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "I'm template a.\nHello "
+ this.escapeExpression(this.lambda(depth0, depth0))
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "!";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand All @@ -14,9 +14,9 @@ define('a.hbs', ['handlebars'], function(Handlebars) {

// Source: src/test/resources/templates/c.hbs
define('c.hbs', ['handlebars'], function(Handlebars) {
var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "I'm template c.\nHello "
+ this.escapeExpression(this.lambda(depth0, depth0))
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "!";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function () {
// Source: src/test/resources/templates/a.hbs

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "I'm template a.\nHello "
+ this.escapeExpression(this.lambda(depth0, depth0))
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "!";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand All @@ -14,9 +14,9 @@

// Source: src/test/resources/templates/c.hbs

var template = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var template = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "I'm template c.\nHello "
+ this.escapeExpression(this.lambda(depth0, depth0))
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "!";
},"useData":true});
var templates = Handlebars.templates = Handlebars.templates || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ public void setFormatters(final Formatter... formatters) {
*
* <pre>
* Handlebars handlebars = new Handlebars()
* .handlebarsJsFile("handlebars-v3.0.3.js");
* .handlebarsJsFile("handlebars-v4.0.4.js");
* </pre>
*
* Default handlebars.js is <code>handlebars-v3.0.3.js</code>.
* Default handlebars.js is <code>handlebars-v4.0.4.js</code>.
*
* @param location A classpath location of the handlebar.js file.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public static CharSequence escapeExpression(final CharSequence input) {
private String endDelimiter = DELIM_END;

/** Location of the handlebars.js file. */
private String handlebarsJsFile = "/handlebars-v3.0.3.js";
private String handlebarsJsFile = "/handlebars-v4.0.4.js";

/** List of formatters. */
private List<Formatter> formatters = new ArrayList<Formatter>();
Expand Down Expand Up @@ -1056,12 +1056,12 @@ public Handlebars with(final Formatter formatter) {
/**
* Set the handlebars.js location used it to compile/precompile template to JavaScript.
* <p>
* Using handlebars.js 3.x:
* Using handlebars.js 4.x:
* </p>
*
* <pre>
* Handlebars handlebars = new Handlebars()
* .handlebarsJsFile("handlebars-v3.0.3.js");
* .handlebarsJsFile("handlebars-v4.0.4.js");
* </pre>
* <p>
* Using handlebars.js 1.x:
Expand All @@ -1072,7 +1072,7 @@ public Handlebars with(final Formatter formatter) {
* .handlebarsJsFile("handlebars-v1.3.0.js");
* </pre>
*
* Default handlebars.js is <code>handlebars-v3.0.3.js</code>.
* Default handlebars.js is <code>handlebars-v4.0.4.js</code>.
*
* @param location A classpath location of the handlebar.js file.
* @return This instance of Handlebars.
Expand All @@ -1091,7 +1091,7 @@ public Handlebars handlebarsJsFile(final String location) {

/**
* @return Classpath location of the handlebars.js file. Default is:
* <code>handlebars-v3.0.3.js</code>
* <code>handlebars-v4.0.4.js</code>
*/
public String handlebarsJsFile() {
return handlebarsJsFile;
Expand Down
Loading

0 comments on commit 749f867

Please sign in to comment.