JavaScript 模板引擎 tpl.js

码农软件 · 软件分类 · 模板引擎 · 2019-08-23 16:28:29

软件介绍

一个轻量的(仅1kb),极速的javascript 模板引擎。

 支持预编译,支持嵌入原生javascript语法,忽略不存在的变量,可直接在AMD、CMD以及全局环境中使用。

使用方法:

1.引入tpl.js

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

或者在Sea.js和Node.js中:

var tpl = require('path/to/tpl');

2.HTML模板

<div id="view"></div>

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

3.执行渲染

console.log( tpl('#demo', {author: "Jony", languages:["javascript", "php", "shell"]}) );

 结果为: 

<p>Hi, I'm Jony</p>
<p>I can write: javascript, php, shell</p>

 

在线例子:http://niceue.github.io/tpl.js/

在线文档:https://github.com/niceue/tpl.js 

本文地址:https://www.codercto.com/soft/d/13006.html

Rapid Web Applications with TurboGears

Rapid Web Applications with TurboGears

Mark Ramm、Kevin Dangoor、Gigi Sayfan / Prentice Hall PTR / 2006-11-07 / USD 44.99

"Dear PHP, It's over between us. You can keep the kitchen sink, but I want my MVC. With TurboGears, I was able to shed the most heinous FileMaker Pro legacy 'solu-tion' imaginable. It has relationshi......一起来看看 《Rapid Web Applications with TurboGears》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具