Skip to content

wowhy/test

Repository files navigation

test

<script type="text/javascript"> function compile(symbols) { var execute; var fn = 'execute = function(element, data){ '; fn += "var html = \'\';"; $.each(symbols, function (i, p) { if (p.tagName != 'for') { } else { } }); fn += 'return html;'; fn += '}'; eval(fn); return execute; } $.fn.extend({ template: function (tpl, data) { var symbols = $(tpl); var me = this; var innerHtml = ''; if (symbols.length) { var fn = compile(symbols); innerHtml = fn(me, data); } innerHtml = test(me, data); this.html(innerHtml); } }); $('#container').template( '

{name}

{text}', { name: '测试', rows: [{ link: '#1', text: '链接1' }, { link: '#2', text: '链接2' }] }); function test(element, data) { var html = ''; html += '

' + data.name + '

'; $.each(data.rows, function (i, n) { html += '' + n.text + ''; }); return html; } </script>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages