Features
Some Example Code
Template:
[sourcecode language=”php”]
<script type="text/x-pisi-template" id="al_pacino_movies">
<h4>Al Pacino Movies</h4><ul>
<% for(var i = 0; i < pacino.length; i ++) { %>
<li><a href="http://www.imdb.com/find?q=<%= pacino[i].replace(/s/g, ‘+’) %>&s=tt" title="Search IMDB for <%= pacino[i] %>" target="_blank"><%= pacino[i] %></a></li>
<% } %>
</ul></script>[/sourcecode]
Data Object:
[sourcecode language=”javascript”]
var pacino = ["Serpico", "Dog Day Afternoon", "Scent of A Woman", "Insomnia", "Carlito’s Way", "Heat"]
[/sourcecode]
Template Call:
[sourcecode language="javascript"]
_pisi.setExternal([{
template: "al_pacino_movies",
data: pacino,
callback: function(html) {
document.getElementById("movies").innerHTML = html;
}
]}
[/sourcecode]Rendered Markup:
[sourcecode language="xml"]
<h4>Al Pacino Movies</h4>
<ul>
<li><a target="_blank" title="Search IMDB for Serpico" href="http://www.imdb.com/find?q=Serpico&s=tt">Serpico</a></li>
<li><a target="_blank" title="Search IMDB for Dog Day Afternoon" href="http://www.imdb.com/find?q=Dog+Day+Afternoon&s=tt">Dog Day Afternoon</a></li>
<li><a target="_blank" title="Search IMDB for Scent of A Woman" href="http://www.imdb.com/find?q=Scent+of+A+Woman&s=tt">Scent of A Woman</a></li>
<li><a target="_blank" title="Search IMDB for Insomnia" href="http://www.imdb.com/find?q=Insomnia&s=tt">Insomnia</a></li>
<li><a target="_blank" title="Search IMDB for Carlito's Way" href="http://www.imdb.com/find?q=Carlito's+Way&s=tt">Carlito's Way</a></li>
<li><a target="_blank" title="Search IMDB for Heat" href="http://www.imdb.com/find?q=Heat&s=tt">Heat</a></li>
</ul>
[/sourcecode]If the above looks and sounds cool enough, you can go to Pisi's home page, view the demo or download it and use it in your own projects. You can also check Templatr - another cool fully client-side JSON to HTML template engine by Acid.JS Web.UI.
Categories and Tags
© 2006 - 2025 Martin Ivanov