Mockup用到的Backbone 简单介绍

Mockup用到的Backbone 简单介绍

Mockup应用Backbone.js来做前端js框架。

Backbone’s Templates 语法说明Backbone has a utility/helper library called underscore.js (underscore是为java-script提供函数式编程的扩展库,Backbone依存于underscore)and you can use their template solution out of box. You can also use any other template solution that you want like mustache or handlebars. Let’s stick with _.js for simplicity’s sake._.js templates have the following syntax,_.template(templateString, [data], [settings])where in the templateString you use the place holder

 <%= %>

and

 <%- %>

to dynamically insert data. The later allows for HTML escape while the first one doesn’t. Moreover, you can use

<% %>

to run any javascript code.
Mockup用到requirejs 的text插件来载入模板(也可以载入其他文本资源,如css,js,html等等),模板文件往往采用xml后缀,此时,这类xml文件模板
遵循上面的语法。

设置