Coder Social home page Coder Social logo

guoyu07 / fis3-parser-dot-compiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coooold/fis3-parser-dot-compiler

0.0 0.0 0.0 5 KB

is3-parser-dot-compiler插件基于fis3,提供将dot模板文件编译为纯js模板函数的功能。 编译后可以提升前端渲染性能,并且无需引入doT库文件。

License: MIT License

JavaScript 100.00%

fis3-parser-dot-compiler's Introduction

doT.js是一款高效的JS模板编译引擎。fis3-parser-dot-compiler插件基于fis3,提供将dot模板文件编译为纯js模板函数的功能。 编译后可以提升前端渲染性能,并且无需引入doT库文件。

##使用方法 在fis.conf中增加以下配置:

fis.match('*.dot', {
	parser: fis.plugin('dot-compiler', {varname: 'it'}),
	rExt: '.js'
})

将项目中的dot结尾的文件编译为同名js文件。

例如a.dot:

    <div class="wrap"> 
		<div class="cate_ranknews" data-js="rank">
			<span class="cate_rankicon"></span>
			<span class="cate_rankmore"><em class="moreicon"></em></span>
			<div cl ass="cate_rankfont">
				<h2>书城排行榜</h2>
				<p>今日男生榜、女生榜、新书榜等{{=it}}个榜更新</p>
			</div>
		</div>
	</div>
	<div class="blank_base"></div>

将会编译为:

$["a"]=function(it
/**/) {
var out=' <div class="wrap"> <div class="cate_ranknews" data-js="rank"><span class="cate_rankicon"></span><span class="cate_rankmore"><em class="moreicon"></em></span><div cl ass="cate_rankfont"><h2>书城排行榜</h2><p>今日男生榜、女生榜、新书榜等'+(it)+'个榜更新</p> </div></div></div><div class="blank_base"></div>';return out;
}

模板文件名.dot将会被编译成$("模板文件名")的模板函数。

##在网页中使用模板

//在js文件中导入模板
@require "./tmpl/tmpl_category_rank_news.dot"

//渲染
document.write($["a"](it));

##其他 可以配合fis3-prepackager-dot-compiler,将所有模板文件打包到一个js文件中,便于前端引用。

fis3-parser-dot-compiler's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.