NSmarty is a ported PHP Smarty template engine. NSmarty suport all well known: variable output, variable modifiers, block, assign, include, loop through arrays and more.
Also, NSmarty have a strong caching feature which make your application very faster.
Using client side templates lets you avoid hassle of tedious and error-prone manual manipulations with strings and DHTML objects, and helps you create Model-View-Controller JavaScript application where the presentation and the logic are clearly separated.
Although there are a lot of browser-side Javascript template engines available, NSmarty has some unique features that sets this project apart from the rest.
jSmart implements rich and well established syntax of the popular PHP template engine Smarty familiar to many developers around the world. Together with limitied build-in support for PHP language constructs and libraries like php.js it creates possibility to use the same set of templates both on the server and the client side.
NSmarty documentation is still incomplete, but you can use Smarty documentation on www.smarty.net/docs/en/. Almost all of Smarty 3 (and Smarty 2) syntax is supported.
// Authors: Dorin Grigoras , Max Miroshnikov.
// http://www.gnu.org/licenses/lgpl.html
{$a = ['a','b','c','d']}
{$a|count} //== 4
{$person = [name=>[first=>'John',last=>'Doe'], age=>36]}
{$person|count} //== 2
{$person|count:1} //== 4
{$foo = bar}
{$foo|regex_replace:'/b/':'z'} //zar
Parameter Position Required Default Description
1 No 80 This determines how many columns to wrap to.
2 No \n This is the string used to wrap words with.
3 No FALSE This determines whether or not to wrap at a word boundary (FALSE), or at the exact character (TRUE).