Skip to content

Instantly share code, notes, and snippets.

@tiborsaas
Created April 12, 2012 10:40
Show Gist options
  • Save tiborsaas/2366406 to your computer and use it in GitHub Desktop.
Save tiborsaas/2366406 to your computer and use it in GitHub Desktop.
jSmart wrapper for jQuery
/*********************************************************************
* A wrapper for jSmart template engine to make it work with jQuery
* Project URL: http://code.google.com/p/jsmart/
********************************************************************/
var Smarty = function( template_id, data )
{
var target = $( '#' + template_id );
if( !target )
{
return false;
}
var tplObj = new jSmart( target.html() );
return {
fetch: function()
{
$.noConflict();
var html = tplObj.fetch( data );
$ = jQuery;
return html;
},
display: function( container )
{
var target_element = ( typeof container == 'string' ) ? $( '#' + container ) : $( container );
if( !target_element )
{
return false;
}
$.noConflict();
var html = tplObj.fetch( data );
$ = jQuery;
target_element.html( html );
return html;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment