Skip to content

Instantly share code, notes, and snippets.

@tinyrobot
Created May 3, 2013 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinyrobot/5515012 to your computer and use it in GitHub Desktop.
Save tinyrobot/5515012 to your computer and use it in GitHub Desktop.
Ideas for selector based server side templating with node
//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