Skip to content

Instantly share code, notes, and snippets.

@seanmonstar
Created August 4, 2011 18:15
Show Gist options
  • Select an option

  • Save seanmonstar/1125808 to your computer and use it in GitHub Desktop.

Select an option

Save seanmonstar/1125808 to your computer and use it in GitHub Desktop.
Template file, and compiled into a function
View.$cache["tasks"]= function(obj){
var p=[],
print=function(){
p.push.apply(p,arguments)
};
with(obj){
p.push('<form action="" method="post"><label><input type="text" name="title" placeholder="Task title..." /></label><button type="submit">Add Task</button></form><ul id="TasksList">');
tasks.each(function(t){
p.push('<li class="task ', t.identity(), '"><span class="title">', t.get("title"), '</span><a href="#" class="delete">Delete</a></li>')
});
p.push("</ul>")
}
return p.join("")
};
<form action="" method="post">
<label>
<input type="text" name="title" placeholder="Task title..." />
</label>
<button type="submit">Add Task</button>
</form>
<ul id="TasksList">
<% tasks.each(function(t) { %>
<li class="task <%=t.identity()%>">
<span class="title"><%=t.get('title')%></span>
<a href="#" class="delete">Delete</a>
</li>
<% }); %>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment