Created
June 18, 2018 19:26
-
-
Save mjumbewu/d7e82fee9aa416aced0425d90e628447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// template.js | |
var {each} = require('jstemplates/utils'); | |
var childelem = require('jstemplates/package/childelem'); | |
function render(data) { | |
return ` | |
<html> | |
<ul> | |
${data.elems.map(childelem.render).join('')} | |
${each(data.elems, childelem.render)} | |
</ul> | |
</html>` | |
} | |
// childelem.js | |
function render(elem, index, elems) { | |
let classes = (index == elems.length - 1 ? 'last' : ''); | |
return `<li class="${classes}">${elem.name}</li>` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment