Framework7-templates-overview
提供:Dev Guides
Framework7-テンプレートの概要
説明
Template7は軽量のモバイルファーストJavaScriptエンジンです。これは、指定されたコンテキストを持つTemplate7テンプレートとしてAjaxおよび動的ページを表し、追加のスクリプトを必要としません。 Template7は、デフォルトの軽量テンプレートエンジンとしてFramework7に関連付けられており、アプリケーションでより高速に動作します。
パフォーマンス
文字列をJS関数にコンパイルするプロセスは、template7の最も遅いセグメントです。 したがって、テンプレートを複数回コンパイルする必要はなく、1回で十分です。
//Here initialize the app
var myApp = new Framework7();
//After initializing compile templates on app
var searchTemplate = $('script#search-template')l();
var compiledSearchTemplate = Template7.compile(searchTemplate);
var listTemplate = $('script#list-template')l();
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ファイルは、2つの方法を使用してインストールできます-
- Template7 github repositoryからダウンロードできます。
- 次のコマンドを使用してBowerからインストールできます-
bower install template7