Last active
August 29, 2015 14:01
-
-
Save allanesquina/509026963579b865b869 to your computer and use it in GitHub Desktop.
Render function
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
function render( tplName, data ) { | |
try { | |
var tpl = $( '#' + tplName )[0].innerHTML || {}, | |
k, rx = /{\|\|.*?\|\|}/g, tmp ; | |
for( k in data ) { | |
tmp = new RegExp( '{\\|\\|data\\.'+ k +'\\|\\|}', 'g' ); | |
tpl = tpl.replace( tmp, data[ k ] ); | |
} | |
//Limpa dados que não foram encontrados | |
while ( tpl.match( rx ) ) { | |
tpl = tpl.replace( rx , ''); | |
} | |
return tpl; | |
} catch ( e ) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment