Framework7 - 模板概述

描述

Template7是一个轻量级,移动优先的JavaScript引擎,它将Ajax和动态页面表示为具有指定上下文的Template7模板,不需要任何其他脚本. Template7与Framework7相关联,作为默认的轻量级模板引擎,对应用程序的工作速度更快.

性能

将字符串编译为JS函数的过程是template7中最慢的部分.因此,您不需要多次编译模板,只需一次即可.

//Here initialize the app
var myApp = new Framework7();

// After initializing compile templates on app
var searchTemplate = $('script#search-template').html();
var compiledSearchTemplate = Template7.compile(searchTemplate);

var listTemplate = $('script#list-template').html();
var compiledListTemplate = Template7.compile(listTemplate);

// Execute the compiled templates with required context using onPageInit() method
myApp.onPageInit('search', function (page) {

   // Execute the compiled templates with required content
   var html = compiledSearchTemplate({/*...some data...*/});

   // Do stuff with html
});

Template7是一个轻量级模板引擎,用作没有Framework7的独立库. Template7文件可以使用两种方式安装 :

  • 您可以从Template7下载 github repository .

  • 你可以通过Bower : 使用以下命令安装它;

bower install template7