jsutils/file
最新稳定版本:0.1.9
Composer 安装命令:
composer require jsutils/file
包简介
Javascript File Utility
README 文档
README
##getJSON load JSON file from server and applies dummyJSON if data is passed.
//my_server/my_json_file.json { "people": { "id" : "{{data.id}}" } } //Client Side Code var fileUtil = _module_("jsutils.file"); fileUtil.getJSON("my_server/my_json_file.json",{ id : 100}).done(function(resp){ //formatted json }); //OUTPUT FORMATTED { "people": { "id" : "100" } }
##getHTML load HTML file from server, applies underscore templating on it.
//my_server/my_html_file.html <div> <strong>Hi, Data id is {{data.id}}</strong> </div> //Client Side Code var fileUtil = _module_("jsutils.file"); fileUtil.getHTML("my_server/my_html_file.html",{ id : 100}).done(function(resp){ //formatted html }); //OUTPUT FORMATTED <div> <strong>Hi, Data id is 100</strong> </div>
Include Nested HTML
If template contains include tag, then nested HTML template is applied. Data can be passed as you wish to nested template.
//my_server/in_other_folder_my_other_html_file.html <div> <strong>And My name is {{data.name}}</strong> </div> //my_server/my_html_file2.html <div> <strong>Hi, Data id is {{data.id}}</strong> <include src="in_other_folder_my_other_html_file.html" data=data.user /> </div> //Client Side Code var fileUtil = _module_("jsutils.file"); fileUtil.getHTML("my_server/my_html_file2.html",{ id : 100, user : { name : "Lalit" } }).done(function(resp){ //formatted html }); //OUTPUT <div> <strong>Hi, Data id is {{data.id}}</strong> <div> <strong>And My name is Lalit</strong> </div> </div>
统计信息
- 总下载量: 86
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-14