Last active
August 29, 2015 14:02
-
-
Save mamboer/d905cb85c6eb0bf53f48 to your computer and use it in GitHub Desktop.
API of xhogan.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 将指定数据渲染指定模板 | |
* @param {Object} opts 配置对象 | |
* @param {String} opts.target 渲染目标的css选择器,例如#test | |
* @param {String} opts.tpl 模板的id选择器或者模板的内容(支持远程模板文件例如http://faso.me/xhogan/tpl/test.html)。如果是模板id,需要以#开始,例如#tpl1 | |
* @param {String} opts.data 渲染模板所需数据,json对象或者远程json文件例如http://faso.me/xhogan/data/test.json | |
* @param {String} opts.tplVersion 模板版本号 | |
* @param {String} opts.dataVersion 数据版本号 | |
* @param {String} opts.appendToTarget 是否将最后的dom追加到目标元素中 | |
* @param {Object} opts.extraTplData 模板渲染的额外数据 | |
* @param {Function} opts.cbk 回调函数cbk(err,html,tpl,data) | |
* @param {String} opts.dataType 数据格式,默认json | |
*/ | |
xhogan.render({ | |
target:"body", | |
tpl:"#xhoganTpl", | |
data:{}, | |
extraTplData:null, | |
tplVersion:"1", | |
dataVersion:"1", | |
appendToTarget:true, | |
dataType:'json', | |
cbk:function(err,html,tpl,data){} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment