Added test for templateRoot.prependChild

This commit is contained in:
Patrick Steele-Idem 2016-02-04 16:24:51 -07:00
parent d28ea9ba33
commit ee4fc809b2
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,24 @@
function create(__helpers) {
var str = __helpers.s,
empty = __helpers.e,
notEmpty = __helpers.ne,
escapeXml = __helpers.x;
return function render(data, out) {
out.w("<ul>");
forEach(data.colors, function(color) {
foo();
out.w("<li>" +
escapeXml(color) +
"</li>");
bar();
});
out.w("</ul>");
};
}
(module.exports = require("marko").c(__filename)).c(create);

View File

@ -0,0 +1,20 @@
'use strict';
module.exports = function(builder) {
var templateRoot = builder.templateRoot([
builder.htmlElement(
'div',
[])
]);
templateRoot.prependChild(builder.vars([
{
id: 'foo',
init: builder.literal('bar')
}
]));
console.log(templateRoot.body.items);
return templateRoot;
};