Comparing version 0.1.13 to 0.2.0
@@ -25,3 +25,3 @@ define("htmlbars-runtime", | ||
var template = env.partials[params[0]]; | ||
return template(this, env, options.morph.contextualElement); | ||
return template.render(this, env, options.morph.contextualElement); | ||
} | ||
@@ -118,3 +118,3 @@ | ||
} | ||
element.appendChild(options.render(context, env, morph.contextualElement)); | ||
element.appendChild(options.template.render(context, env, morph.contextualElement)); | ||
return element; | ||
@@ -121,0 +121,0 @@ } |
@@ -26,3 +26,3 @@ "use strict"; | ||
var template = compile(html); | ||
var fragment = template(context, env, document.body); | ||
var fragment = template.render(context, env, document.body); | ||
equalTokens(fragment, expected === undefined ? html : expected); | ||
@@ -78,3 +78,3 @@ return fragment; | ||
var template = compile("content"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -86,3 +86,3 @@ equalTokens(fragment, "content"); | ||
var template = compile("<h1>hello!</h1><div>content</div>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -94,3 +94,3 @@ equalTokens(fragment, "<h1>hello!</h1><div>content</div>"); | ||
var template = compile("<div class='foo' id='bar'>content</div>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -102,3 +102,3 @@ equalTokens(fragment, '<div class="foo" id="bar">content</div>'); | ||
var template = compile("<div class=''>content</div>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -110,3 +110,3 @@ equalTokens(fragment, '<div class="">content</div>'); | ||
var template = compile('<input disabled="{{isDisabled}}">'); | ||
var fragment = template({isDisabled: null}, env); | ||
var fragment = template.render({isDisabled: null}, env); | ||
@@ -119,3 +119,3 @@ equalTokens(fragment, '<input disabled="null">'); | ||
var template = compile('<input disabled={{isDisabled}}>'); | ||
var fragment = template({isDisabled: null}, env); | ||
var fragment = template.render({isDisabled: null}, env); | ||
@@ -128,3 +128,3 @@ equalTokens(fragment, '<input>'); | ||
var template = compile('<input value=funstuff>'); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -137,3 +137,3 @@ equalTokens(fragment, '<input value="funstuff">'); | ||
var template = compile('<input value={{funstuff}}>'); | ||
var fragment = template({funstuff: "oh my"}, env); | ||
var fragment = template.render({funstuff: "oh my"}, env); | ||
@@ -145,3 +145,3 @@ equalTokens(fragment, '<input value="oh my">'); | ||
var template = compile("<div data-some-data='foo'>content</div>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
equalTokens(fragment, '<div data-some-data="foo">content</div>'); | ||
@@ -152,3 +152,3 @@ }); | ||
var template = compile("<input checked=\"checked\">"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
ok(fragment.checked, 'input is checked'); | ||
@@ -160,3 +160,3 @@ equalTokens(fragment, "<input checked='checked'>"); | ||
var template = compile("<svg viewBox=\"0 0 0 0\"></svg>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
equalTokens(fragment, '<svg viewBox=\"0 0 0 0\"></svg>'); | ||
@@ -168,3 +168,3 @@ }); | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -194,3 +194,3 @@ | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -262,3 +262,3 @@ equalTokens(fragment, html); | ||
var context = { html: '<tr><td>Yo</td></tr>' }; | ||
var fragment = template(context, env, document.createElement('table')); | ||
var fragment = template.render(context, env, document.createElement('table')); | ||
@@ -273,3 +273,3 @@ equal( | ||
var context = { html: '<td>Yo</td>' }; | ||
var fragment = template(context, env, document.createElement('tr')); | ||
var fragment = template.render(context, env, document.createElement('tr')); | ||
@@ -283,3 +283,3 @@ equal( | ||
registerHelper('test', function(params, hash, options, env) { | ||
return options.render(this, env, options.morph.contextualElement); | ||
return options.template.render(this, env, options.morph.contextualElement); | ||
}); | ||
@@ -289,3 +289,3 @@ | ||
var context = { html: '<tr><td>Yo</td></tr>' }; | ||
var fragment = template(context, env, document.createElement('table')); | ||
var fragment = template.render(context, env, document.createElement('table')); | ||
@@ -299,3 +299,3 @@ equal( | ||
registerHelper('test', function(params, hash, options, env) { | ||
return options.render(this, env, options.morph.contextualElement); | ||
return options.template.render(this, env, options.morph.contextualElement); | ||
}); | ||
@@ -305,3 +305,3 @@ | ||
var context = { html: '<tr><td>Yo</td></tr>' }; | ||
var fragment = template(context, env, document.createElement('div')); | ||
var fragment = template.render(context, env, document.createElement('div')); | ||
@@ -435,5 +435,5 @@ equal( | ||
registerHelper('testing-escaped', function(params, hash, options, env) { | ||
if (options.render) { | ||
if (options.template) { | ||
equal(options.morph.escaped, true); | ||
return options.render({}, env, options.morph.contextualElement); | ||
return options.template.render({}, env, options.morph.contextualElement); | ||
} else if (params.length === 0 && emptyHash(hash)) { | ||
@@ -644,3 +644,3 @@ //ambiguous mustache | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.render(context, env)); | ||
morph.update(options.template.render(context, env)); | ||
}; | ||
@@ -653,3 +653,3 @@ | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.render(context, env)); | ||
morph.update(options.template.render(context, env)); | ||
}; | ||
@@ -662,3 +662,3 @@ | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.inverse(context, env)); | ||
morph.update(options.inverse.render(context, env)); | ||
}; | ||
@@ -673,3 +673,3 @@ | ||
if (path === 'testing') { | ||
morph.update(options.render({ title: 'Rails is omakase' }, env)); | ||
morph.update(options.template.render({ title: 'Rails is omakase' }, env)); | ||
} else { | ||
@@ -687,3 +687,3 @@ originalContent.apply(this, arguments); | ||
options.hooks = this; | ||
morph.update(options.render(context, env)); | ||
morph.update(options.template.render(context, env)); | ||
} | ||
@@ -710,3 +710,3 @@ }; | ||
if (value) { | ||
frag = options.render(context); | ||
frag = options.template.render(context); | ||
} else { | ||
@@ -831,3 +831,3 @@ frag = document.createDocumentFragment(); | ||
registerHelper('x-append', function(params, hash, options, env) { | ||
var fragment = options.render(this, env, options.morph.contextualElement); | ||
var fragment = options.template.render(this, env, options.morph.contextualElement); | ||
fragment.appendChild(document.createTextNode(hash.text)); | ||
@@ -868,3 +868,3 @@ return fragment; | ||
var template = compile("<div aria-label='foo'>content</div>"); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -878,3 +878,3 @@ equalTokens(fragment, '<div aria-label="foo">content</div>'); | ||
var span = document.createElement('span'); | ||
span.appendChild(options.render(context, env, document.body, ['W', 'X1'])); | ||
span.appendChild(options.template.render(context, env, document.body, ['W', 'X1'])); | ||
return 'A(' + span.innerHTML + ')'; | ||
@@ -885,3 +885,3 @@ }); | ||
var span = document.createElement('span'); | ||
span.appendChild(options.render(context, env, document.body, ['X2', 'Y'])); | ||
span.appendChild(options.template.render(context, env, document.body, ['X2', 'Y'])); | ||
return 'B(' + span.innerHTML + ')'; | ||
@@ -892,5 +892,5 @@ }); | ||
var span = document.createElement('span'); | ||
span.appendChild(options.render(context, env, document.body, ['Z'])); | ||
span.appendChild(options.template.render(context, env, document.body, ['Z'])); | ||
return 'C(' + span.innerHTML + ')'; | ||
// return "C(" + options.render() + ")"; | ||
// return "C(" + options.template.render() + ")"; | ||
}); | ||
@@ -911,6 +911,6 @@ var t = '{{#a as |w x|}}{{w}},{{x}} {{#b as |x y|}}{{x}},{{y}}{{/b}} {{w}},{{x}} {{#c as |z|}}{{x}},{{z}}{{/c}}{{/a}}'; | ||
compile('{{#without-block-params}}{{/without-block-params}}')({}, env, document.body); | ||
compile('{{#with-block-params as |x|}}{{/with-block-params}}')({ count: 1 }, env, document.body); | ||
compile('{{#with-block-params as |x y|}}{{/with-block-params}}')({ count: 2 }, env, document.body); | ||
compile('{{#with-block-params as |x y z|}}{{/with-block-params}}')({ count: 3 }, env, document.body); | ||
compile('{{#without-block-params}}{{/without-block-params}}').render({}, env, document.body); | ||
compile('{{#with-block-params as |x|}}{{/with-block-params}}').render({ count: 1 }, env, document.body); | ||
compile('{{#with-block-params as |x y|}}{{/with-block-params}}').render({ count: 2 }, env, document.body); | ||
compile('{{#with-block-params as |x y z|}}{{/with-block-params}}').render({ count: 3 }, env, document.body); | ||
}); | ||
@@ -944,3 +944,3 @@ | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -954,3 +954,3 @@ equal(fragment.namespaceURI, svgNamespace, "creates the svg element with a namespace"); | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -965,3 +965,3 @@ equal( fragment.childNodes[0].namespaceURI, svgNamespace, | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -978,3 +978,3 @@ equal( fragment.namespaceURI, svgNamespace, | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -989,3 +989,3 @@ equal( fragment.childNodes[0].childNodes[0].namespaceURI, xhtmlNamespace, | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -1004,3 +1004,3 @@ equal( fragment.childNodes[0].namespaceURI, svgNamespace, | ||
var template = compile(html); | ||
var fragment = template({}, env); | ||
var fragment = template.render({}, env); | ||
@@ -1013,3 +1013,3 @@ equalTokens(fragment, html); | ||
var fragment = template({ name: 'Milly' }, env, document.body); | ||
var fragment = template.render({ name: 'Milly' }, env, document.body); | ||
equal( | ||
@@ -1023,3 +1023,3 @@ fragment.childNodes[0].namespaceURI, svgNamespace, | ||
var fragment = template({ name: 'Milly' }, env); | ||
var fragment = template.render({ name: 'Milly' }, env); | ||
equal( | ||
@@ -1034,3 +1034,3 @@ fragment.childNodes[0].namespaceURI, svgNamespace, | ||
var template = compile('<svg>{{name}}</svg>'); | ||
var fragment = template({ name: 'Milly' }, env); | ||
var fragment = template.render({ name: 'Milly' }, env); | ||
equal( | ||
@@ -1047,5 +1047,5 @@ fragment.namespaceURI, svgNamespace, | ||
if (isTrue) { | ||
morph.update(options.render(context, env, morph.contextualElement)); | ||
morph.update(options.template.render(context, env, morph.contextualElement)); | ||
} else { | ||
morph.update(options.inverse(context, env, morph.contextualElement)); | ||
morph.update(options.inverse.render(context, env, morph.contextualElement)); | ||
} | ||
@@ -1055,3 +1055,3 @@ }; | ||
var fragment = template({ isTrue: true }, env, document.body); | ||
var fragment = template.render({ isTrue: true }, env, document.body); | ||
equal( | ||
@@ -1062,3 +1062,3 @@ fragment.childNodes[1].namespaceURI, svgNamespace, | ||
isTrue = false; | ||
fragment = template({ isTrue: false }, env, document.body); | ||
fragment = template.render({ isTrue: false }, env, document.body); | ||
equal( | ||
@@ -1074,3 +1074,3 @@ fragment.childNodes[1].namespaceURI, xhtmlNamespace, | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.render(context, env, morph.contextualElement)); | ||
morph.update(options.template.render(context, env, morph.contextualElement)); | ||
}; | ||
@@ -1080,3 +1080,3 @@ | ||
var fragment = template({ isTrue: true }, env); | ||
var fragment = template.render({ isTrue: true }, env); | ||
equal( fragment.childNodes[0].namespaceURI, svgNamespace, | ||
@@ -1090,3 +1090,3 @@ "svg tag has an svg namespace" ); | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.render(context, env, morph.contextualElement)); | ||
morph.update(options.template.render(context, env, morph.contextualElement)); | ||
}; | ||
@@ -1096,3 +1096,3 @@ | ||
var fragment = template({ isTrue: true }, env); | ||
var fragment = template.render({ isTrue: true }, env); | ||
equal( fragment.namespaceURI, svgNamespace, | ||
@@ -1106,3 +1106,3 @@ "svg tag has an svg namespace" ); | ||
hooks.content = function(morph, path, context, params, hash, options, env) { | ||
morph.update(options.render(context, env, morph.contextualElement)); | ||
morph.update(options.template.render(context, env, morph.contextualElement)); | ||
}; | ||
@@ -1112,3 +1112,3 @@ | ||
var fragment = template({ isTrue: true }, env, document.createElementNS(svgNamespace, 'svg')); | ||
var fragment = template.render({ isTrue: true }, env, document.createElementNS(svgNamespace, 'svg')); | ||
equal( fragment.namespaceURI, svgNamespace, | ||
@@ -1115,0 +1115,0 @@ "foreignObject tag has an svg namespace" ); |
@@ -33,3 +33,3 @@ "use strict"; | ||
if (params[0]) { | ||
return options.render(context, env, options.morph.contextualElement); | ||
return options.template.render(context, env, options.morph.contextualElement); | ||
} | ||
@@ -43,4 +43,4 @@ }; | ||
}; | ||
var frag = template(context, env, document.body); | ||
var frag = template.render(context, env, document.body); | ||
equalHTML(frag, '<div>Hello Kris Selden!</div>'); | ||
}); |
@@ -15,5 +15,5 @@ "use strict"; | ||
this.source.push(this.indent+'function build(dom) {\n'); | ||
this.source.push('function build(dom) {\n'); | ||
processOpcodes(this, opcodes); | ||
this.source.push(this.indent+'}\n'); | ||
this.source.push(this.indent+'}'); | ||
@@ -20,0 +20,0 @@ return this.source.join(''); |
@@ -35,3 +35,3 @@ "use strict"; | ||
if (programId !== null) { | ||
options.push('render:child' + programId); | ||
options.push('template:child' + programId); | ||
} | ||
@@ -38,0 +38,0 @@ |
@@ -43,3 +43,3 @@ "use strict"; | ||
for (var i = 0; i < this.childTemplates.length; i++) { | ||
vars += indent + 'var child' + i + ' = ' + this.childTemplates[i] + '\n'; | ||
vars += indent + 'var child' + i + ' = ' + this.childTemplates[i] + ';\n'; | ||
} | ||
@@ -69,3 +69,3 @@ } | ||
var options = { | ||
indent: indent + " " | ||
indent: indent + " " | ||
}; | ||
@@ -95,14 +95,17 @@ | ||
this.getChildTemplateVars(indent + ' ') + | ||
fragmentProgram + | ||
indent+' var cachedFragment;\n' + | ||
indent+' return function template(' + templateSignature + ') {\n' + | ||
indent+' var dom = env.dom;\n' + | ||
this.getHydrationHooks(indent + ' ', this.hydrationCompiler.hooks) + | ||
indent+' dom.detectNamespace(contextualElement);\n' + | ||
indent+' if (cachedFragment === undefined) {\n' + | ||
indent+' cachedFragment = build(dom);\n' + | ||
indent+' return {\n' + | ||
indent+' isHTMLBars: true,\n' + | ||
indent+' cachedFragment: null,\n' + | ||
indent+' build: ' + fragmentProgram + ',\n' + | ||
indent+' render: function render(' + templateSignature + ') {\n' + | ||
indent+' var dom = env.dom;\n' + | ||
this.getHydrationHooks(indent + ' ', this.hydrationCompiler.hooks) + | ||
indent+' dom.detectNamespace(contextualElement);\n' + | ||
indent+' if (this.cachedFragment === null) {\n' + | ||
indent+' this.cachedFragment = this.build(dom);\n' + | ||
indent+' }\n' + | ||
indent+' var fragment = dom.cloneNode(this.cachedFragment, true);\n' + | ||
hydrationProgram + | ||
indent+' return fragment;\n' + | ||
indent+' }\n' + | ||
indent+' var fragment = dom.cloneNode(cachedFragment, true);\n' + | ||
hydrationProgram + | ||
indent+' return fragment;\n' + | ||
indent+' };\n' + | ||
@@ -109,0 +112,0 @@ indent+'}())'; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var template = env.partials[params[0]]; | ||
return template(this, env, options.morph.contextualElement); | ||
return template.render(this, env, options.morph.contextualElement); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -82,3 +82,3 @@ "use strict"; | ||
} | ||
element.appendChild(options.render(context, env, morph.contextualElement)); | ||
element.appendChild(options.template.render(context, env, morph.contextualElement)); | ||
return element; | ||
@@ -85,0 +85,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
* See https://raw.githubusercontent.com/tildeio/htmlbars/master/LICENSE | ||
* @version 0.1.13 | ||
* @version 0.2.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ |
@@ -14,5 +14,5 @@ import { processOpcodes } from "./utils"; | ||
this.source.push(this.indent+'function build(dom) {\n'); | ||
this.source.push('function build(dom) {\n'); | ||
processOpcodes(this, opcodes); | ||
this.source.push(this.indent+'}\n'); | ||
this.source.push(this.indent+'}'); | ||
@@ -19,0 +19,0 @@ return this.source.join(''); |
@@ -33,3 +33,3 @@ import { array, hash } from "./quoting"; | ||
if (programId !== null) { | ||
options.push('render:child' + programId); | ||
options.push('template:child' + programId); | ||
} | ||
@@ -36,0 +36,0 @@ |
@@ -42,3 +42,3 @@ import { FragmentOpcodeCompiler } from './fragment_opcode'; | ||
for (var i = 0; i < this.childTemplates.length; i++) { | ||
vars += indent + 'var child' + i + ' = ' + this.childTemplates[i] + '\n'; | ||
vars += indent + 'var child' + i + ' = ' + this.childTemplates[i] + ';\n'; | ||
} | ||
@@ -68,3 +68,3 @@ } | ||
var options = { | ||
indent: indent + " " | ||
indent: indent + " " | ||
}; | ||
@@ -94,14 +94,17 @@ | ||
this.getChildTemplateVars(indent + ' ') + | ||
fragmentProgram + | ||
indent+' var cachedFragment;\n' + | ||
indent+' return function template(' + templateSignature + ') {\n' + | ||
indent+' var dom = env.dom;\n' + | ||
this.getHydrationHooks(indent + ' ', this.hydrationCompiler.hooks) + | ||
indent+' dom.detectNamespace(contextualElement);\n' + | ||
indent+' if (cachedFragment === undefined) {\n' + | ||
indent+' cachedFragment = build(dom);\n' + | ||
indent+' return {\n' + | ||
indent+' isHTMLBars: true,\n' + | ||
indent+' cachedFragment: null,\n' + | ||
indent+' build: ' + fragmentProgram + ',\n' + | ||
indent+' render: function render(' + templateSignature + ') {\n' + | ||
indent+' var dom = env.dom;\n' + | ||
this.getHydrationHooks(indent + ' ', this.hydrationCompiler.hooks) + | ||
indent+' dom.detectNamespace(contextualElement);\n' + | ||
indent+' if (this.cachedFragment === null) {\n' + | ||
indent+' this.cachedFragment = this.build(dom);\n' + | ||
indent+' }\n' + | ||
indent+' var fragment = dom.cloneNode(this.cachedFragment, true);\n' + | ||
hydrationProgram + | ||
indent+' return fragment;\n' + | ||
indent+' }\n' + | ||
indent+' var fragment = dom.cloneNode(cachedFragment, true);\n' + | ||
hydrationProgram + | ||
indent+' return fragment;\n' + | ||
indent+' };\n' + | ||
@@ -108,0 +111,0 @@ indent+'}())'; |
@@ -11,3 +11,3 @@ export function concat(params) { | ||
var template = env.partials[params[0]]; | ||
return template(this, env, options.morph.contextualElement); | ||
return template.render(this, env, options.morph.contextualElement); | ||
} | ||
@@ -14,0 +14,0 @@ |
@@ -81,3 +81,3 @@ import { concat } from "./helpers"; | ||
} | ||
element.appendChild(options.render(context, env, morph.contextualElement)); | ||
element.appendChild(options.template.render(context, env, morph.contextualElement)); | ||
return element; | ||
@@ -84,0 +84,0 @@ } |
@@ -6,3 +6,3 @@ /* | ||
* See https://raw.githubusercontent.com/tildeio/htmlbars/master/LICENSE | ||
* @version 0.1.13 | ||
* @version 0.2.0 | ||
*/ | ||
@@ -9,0 +9,0 @@ |
var packagesConfig = { | ||
"version": "0.1.13", | ||
"revision": "e39a96f295d53d93d283e2787903ec81d919d3f4", | ||
"version": "0.2.0", | ||
"revision": "29d93ddbd491f7f48fa1561e592743861ddf659e", | ||
"vendored": {}, | ||
@@ -5,0 +5,0 @@ "dependencies": { |
{ | ||
"name": "htmlbars", | ||
"version": "0.1.13", | ||
"version": "0.2.0", | ||
"description": "HTMLBars compiles Handlebars templates into document fragments rather than string buffers", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/htmlbars.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1214769
35869