3 Star 1 Fork 0

Gitee 极速下载/tpl-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/niceue/tpl.js
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

tpl.js

Lightweight javascript template engine. Adaptation AMD, CMD and global environment

Speed Test

Usage

  1. Include tpl.js:
    <script type="text/javascript" src="path/to/tpl.js"></script>

Or in sea.js, you can include by: var tpl = require('path/to/tpl');

  1. Template in your html:
    <script type="text/template" id="demo">
        <p>Hi, I'm <#=author#></p>
        <p>I can write:
        <# for(var i=0; i<languages.length; i++) { #>
        <#=(i===0?"":",")+languages[i]#>
        <#}#>
        </p>
    </script>

Or use internal method echo():

    <script type="text/template" id="demo">
        <p>Hi, I'm <#=author#></p>
        <p>I can write:
        <# 
        for(var i=0; i<languages.length; i++) { 
            echo( (i===0?"":", ") + languages[i] );
        }#>
        </p>
    </script>
  1. Execution rendering:
    console.log( tpl('#demo', {author: "Jony", languages: ["javascript", "php", "shell"]}) );
  1. Result is:
<p>Hi, I'm Jony</p>
<p>I can write: javascript, php, shell</p>

API

Include another template: <# include("#tpl_id") #>
Get HTML: tpl(template, data)
Get HTML: tpl(template)(data)
Precompiled: tpl(template)

template can be a html template string or '#' plus an id, This will return a rendered html string.

Browser Support

  • IE6+
  • Chrome
  • Safari 4+
  • Firefox 3.5+
  • Opera

Bugs / Contributions

  • Report a bug
  • To contribute or send an idea, github message me or fork the project

Build

tpl.js use UglifyJS2 you should have installed nodejs and run npm install uglify-js -g.

On Windows, you can run build.bat from root directory and it will package tpl.debug.js into tpl.js.

License

tpl.js is available under the terms of the MIT License.

空文件

简介

tpl-js 是一个轻量的(仅1kb)、极速的 javascript 模板引擎 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/tpl-js.git
git@gitee.com:mirrors/tpl-js.git
mirrors
tpl-js
tpl-js
master

搜索帮助