Created
August 16, 2012 15:17
-
-
Save dievardump/3370941 to your computer and use it in GitHub Desktop.
simily Zencoding Template Engine
This file contains 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
var template = '(div[id=menu, class={menu.menuclass}]>ul>li[class={menu.itemclass}, html={title}, map={menu.items}])+(div[class=body]>div[class=content]>p[html={maincontent}])', | |
data = { | |
maincontent: 'foo bar', | |
menu: { | |
menuclass: 'menu', | |
itemclass: 'menu-item', | |
items: [ | |
{ title: 'first entry' }, | |
{ title: 'second entry' }, | |
{ title: 'third entry' }, | |
{ title: 'fourth entry' } | |
] | |
} | |
}; | |
Template.render(template, data); | |
/* | |
<div id='menu' class='menu'> | |
<ul> | |
<li class='menu-item'>first item</li> | |
<li class='menu-item'>second item</li> | |
<li class='menu-item'>third item</li> | |
<li class='menu-item'>fourth item</li> | |
</ul> | |
</div> | |
<div class='body'> | |
<div class='content'> | |
<p>foo bar</p> | |
</div> | |
</div> | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment