mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
37 lines
779 B
JavaScript
37 lines
779 B
JavaScript
module.exports = function create(helpers) {
|
|
var empty = helpers.e,
|
|
notEmpty = helpers.ne,
|
|
escapeXmlAttr = helpers.xa,
|
|
escapeXml = helpers.x,
|
|
forEach = helpers.f;
|
|
|
|
return function render(data, context) {
|
|
var rootClass=data.rootClass;
|
|
|
|
var colors=data.colors;
|
|
|
|
var message=data.message;
|
|
|
|
context.w('<div class="hello-world ')
|
|
.w(escapeXmlAttr(rootClass))
|
|
.w('">')
|
|
.w(escapeXml(message))
|
|
.w('</div>');
|
|
|
|
if (notEmpty(colors)) {
|
|
context.w('<ul>');
|
|
|
|
forEach(colors, function(color) {
|
|
context.w('<li class="color">')
|
|
.w(escapeXml(color))
|
|
.w('</li>');
|
|
});
|
|
|
|
context.w('</ul>');
|
|
}
|
|
|
|
if (empty(colors)) {
|
|
context.w('<div>No colors!</div>');
|
|
}
|
|
};
|
|
} |