|
| 1 | +package com.github.jknack.handlebars.issues; |
| 2 | + |
| 3 | +import com.github.jknack.handlebars.v4Test; |
| 4 | +import org.junit.Test; |
| 5 | + |
| 6 | +import java.io.IOException; |
| 7 | + |
| 8 | +public class Issue550 extends v4Test { |
| 9 | + @Test |
| 10 | + public void precompileAMDShouldNotAddSuffixToTemplatePartialHash() throws IOException { |
| 11 | + shouldCompileTo("{{precompile 'foo' wrapper='amd'}}{{precompile 'bar' wrapper='amd'}}", |
| 12 | + $("partials", $( |
| 13 | + "foo", "<div>Some repeated pattern {{#each listItem}} {{> bar}} {{/each}} </div>", |
| 14 | + "bar", "<div>{{text}}</div>")), |
| 15 | + "define('foo.hbs', ['handlebars'], function(Handlebars) {\n" |
| 16 | + + " var template = Handlebars.template({\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n" |
| 17 | + + " var stack1;\n" |
| 18 | + + "\n" |
| 19 | + + " return \"<div>Some repeated pattern \"\n" |
| 20 | + + " + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.listItem : depth0),{\"name\":\"each\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.noop,\"data\":data})) != null ? stack1 : \"\")\n" |
| 21 | + + " + \" </div>\";\n" |
| 22 | + + "},\"1\":function(container,depth0,helpers,partials,data) {\n" |
| 23 | + + " var stack1;\n" |
| 24 | + + "\n" |
| 25 | + + " return \" \"\n" |
| 26 | + + " + ((stack1 = container.invokePartial(partials.bar,depth0,{\"name\":\"bar\",\"data\":data,\"helpers\":helpers,\"partials\":partials,\"decorators\":container.decorators})) != null ? stack1 : \"\")\n" |
| 27 | + + " + \" \";\n" |
| 28 | + + "},\"usePartial\":true,\"useData\":true});\n" |
| 29 | + + " var templates = Handlebars.templates = Handlebars.templates || {};\n" |
| 30 | + + " templates['foo'] = template;\n" |
| 31 | + + " var partials = Handlebars.partials = Handlebars.partials || {};\n" |
| 32 | + + " partials['foo'] = template;\n" |
| 33 | + + " return template;\n" |
| 34 | + + "});define('bar.hbs', ['handlebars'], function(Handlebars) {\n" |
| 35 | + + " var template = Handlebars.template({\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n" |
| 36 | + + " var helper;\n" |
| 37 | + + "\n" |
| 38 | + + " return \"<div>\"\n" |
| 39 | + + " + container.escapeExpression(((helper = (helper = helpers.text || (depth0 != null ? depth0.text : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : {},{\"name\":\"text\",\"hash\":{},\"data\":data}) : helper)))\n" |
| 40 | + + " + \"</div>\";\n" |
| 41 | + + "},\"useData\":true});\n" |
| 42 | + + " var templates = Handlebars.templates = Handlebars.templates || {};\n" |
| 43 | + + " templates['bar'] = template;\n" |
| 44 | + + " var partials = Handlebars.partials = Handlebars.partials || {};\n" |
| 45 | + + " partials['bar'] = template;\n" |
| 46 | + + " return template;\n" |
| 47 | + + "});"); |
| 48 | + } |
| 49 | +} |
0 commit comments