有人在Github上面建了一个很有意思的项目。你只需要JS就可以创建网页。原理其实很简单,创建一些“html函数”,如: p, div, ul, li 来创建你的网页,而且可以和backbone无缝结合, 下面有个例子:
h1('HTML Creation');p('Tags are functions.')p('Attributes are objects...', { style:{fontStyle:'italic'}})ul(function(){ li('Nest'); li('with'); li('functions!');});
效果:
Tags are functions.
Attributes are objects...
你也用JS来设置些CSS
h1('CSS Creation')css({ '.red':{color:'#e00'}, '.big':{fontSize:'25px'}});div({'class':'red'}, 'This is red');div({c:'big'}, 'This is big');div({c:'big red'}, 'This is both');
效果:
This is red
This is big
This is both
Github地址: https://github.com/ojjs/oj/