Skip to content

Instantly share code, notes, and snippets.

@gmilby
Created April 14, 2012 15:42
Show Gist options
  • Save gmilby/2385296 to your computer and use it in GitHub Desktop.
Save gmilby/2385296 to your computer and use it in GitHub Desktop.
BRANKO: amd - bad idea to sub-template....
var t_stats = '<li class="bar {{this_color}}" style="height: {{css_px}}px;"><div class="top"></div><div class="bottom"></div><span>{{lang}}-{{lang_math}}%</span></li>';
$frag = '';
$.each( data, function( idx, obj ) {
$frag +=
t_stats
//.replace( /{{this_idx}}/ig, idx+1 )
.replace( /{{this_color}}/ig, 'red') //rand(root.bar_colors) )
.replace( /{{lang}}/ig, obj.lang)
.replace( /{{css_px}}/ig, obj.css_px)
.replace( /{{lang_math}}/ig, obj.percent);
});
frag = $frag.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
$('body').append(template.render(tMain,{time: new Date(),stats:frag}));
console.log(frag);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment