Created
April 12, 2012 10:40
-
-
Save tiborsaas/2366406 to your computer and use it in GitHub Desktop.
jSmart wrapper for jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************* | |
* 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