Created
May 3, 2013 23:16
-
-
Save tinyrobot/5515012 to your computer and use it in GitHub Desktop.
Ideas for selector based server side templating with node
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
//data | |
var person = {name: "Dave", exampleattr: "true", friends: ["one","two","three"]}; | |
//map data to selectors | |
var mapping = { | |
name: "#people .person", | |
exampleattr: {"#people .person" : "someattr"}, | |
friends: "#people .friends" | |
}; | |
//input | |
<div id="people"> | |
<span class="person"></span> | |
<ul> | |
<li class="friends"></li> | |
</ul> | |
</div> | |
//output | |
<div id="people"> | |
<span class="person"></span> | |
<ul> | |
<li class="friends">one</li> | |
<li class="friends">two</li> | |
<li class="friends">three</li> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment