日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

java 前端模板_前端模板引擎入门

發布時間:2023/12/14 HTML 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 前端模板_前端模板引擎入门 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

模板引擎

模板引擎 起到 數據和視圖分離的作用, 模板對應視圖, 關注如何展示數據, 在模板外頭準備的數據, 關注那些數據可以被展示。

后端模板引擎

freemarker

如下介紹,? java后臺的模板引擎, freemark介紹,其圖能很好標明這種關系。

Apache FreeMarker is a template engine: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language (not a full-blown programming language like PHP). You meant to prepare the data to display in a real programming language, like issue database queries and do business calculations, and then the template displays that already prepared data. In the template you are focusing on how to present the data, and outside the template you are focusing on what data to present.

velocity

另外一個 java模板引擎, velocity:

velocity是一個基于java的模板引擎, 它允許任何人使用簡單但是強大的 模板語言, 引用 java代碼中的對象。

Velocity is a Java-based template engine. It permits anyone to use a simple yet powerful template language to reference objects defined in Java code.

按照MVC的思想分離任務, web頁面開發者關注如何將頁面做的好看, 業務開發者關注寫首要的邏輯代碼。

其對 JSP代碼是一種取代。

When Velocity is used for web development, Web designers can work in parallel with Java programmers to develop web sites according to the Model-View-Controller (MVC) model, meaning that web page designers can focus solely on creating a site that looks good, and programmers can focus solely on writing top-notch code. Velocity separates Java code from the web pages, making the web site more maintainable over its lifespan and providing a viable alternative to Java Server Pages (JSPs) or PHP.

不僅僅可以做HTML模板, 也可以做XML和sql其它重復性代碼生成工具。

Velocity's capabilities reach well beyond the realm of the web; for example, it can be used to generate SQL, PostScript and XML from templates.

前端模板引擎

隨著前端技術發展, 和前端處理能力增強, 越來越多的 渲染邏輯在瀏覽器端實現, 由此出現前端模板引擎, 仿照后臺模板引擎方法, 定義前端模板語言, 實現前端模板引擎。

arttemplate

新一代 javascript 模板引擎

編寫模板

使用一個type="text/html"的script標簽存放模板:

{{title}}

{{each list as value i}}

索引 {{i + 1}} :{{value}}

{{/each}}

渲染模板

var data = {

title: '標簽',

list: ['文藝', '博客', '攝影', '電影', '民謠', '旅行', '吉他']

};

var html = template('test', data);

document.getElementById('content').innerHTML = html;

arttemplate 性能介紹

artTemplate 介紹

artTemplate 是新一代 javascript 模板引擎,它采用預編譯方式讓性能有了質的飛躍,并且充分利用 javascript 引擎特性,使得其性能無論在前端還是后端都有極其出色的表現。在 chrome 下渲染效率測試中分別是知名引擎 Mustache 與 micro tmpl 的 25 、 32 倍。

art-template結合tomjs編譯工具效果更佳

如果在頁面中維護很多

此工具允許各個模板獨自文件管理, 然后精怪此工具合并壓縮, 成為一個可引用的模板文件:

使用默認的格式

TmodJS 默認將整個目錄的模板壓縮打包到一個名為 template.js 的腳本中,可直接在頁面中使用它:

var html = template('news/list', _list);

document.getElementById('list').innerHTML = html;

template.js 還支持 RequireJS、SeaJS、NodeJS 加載。示例

指定格式(amd / cmd / commonjs)

此時每個模板就是一個單獨的模塊,無需引用 template.js:

var render = require('./tpl/build/news/list');

var html = render(_list);

jquery template模板引擎

http://www.cnblogs.com/FoundationSoft/archive/2010/05/19/1739257.html

http://www.cnblogs.com/whitewolf/archive/2011/10/09/2204185.html

https://github.com/BorisMoore/jquery-tmpl

varmovies=[

{ Name:"The Red Violin", ReleaseYear:"1998"},

{ Name:"Eyes Wide Shut", ReleaseYear:"1999"},

{ Name:"The Inheritance", ReleaseYear:"1976"}

];varmarkup= "

${Name} (${ReleaseYear})";/*Compile the markup as a named template*/$.template("movieTemplate", markup );/*Render the template with the movies data and insert

the rendered HTML under the "movieList" element*/$.tmpl("movieTemplate", movies )

.appendTo("#movieList");

總結

以上是生活随笔為你收集整理的java 前端模板_前端模板引擎入门的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。