定制 jsutils/file 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 1
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-14