function $tmpl( t, o ){
for( var i in o ) t = t.replace( new RegExp('{'+i+'}', 'g' ), o[ i ] );
return t;
}
Simple JS Template function
$tmpl( 'Hello {name}! {say}', { name: 'JavaScript', say: 'Whatsuuuuup!' } );
=> "Hello JavaScript! Whatsuuuuup!"
$tmpl( 'Hello {name}! {say}', { name: 'JavaScript', say: 'Whatsuuuuup!' } );
=> "Hello JavaScript! Whatsuuuuup!"
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.