🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

a-template

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-template

Simple Template Engine used for [gulp-generator](https://github.com/steelydylan/gulp-generator)

0.0.2
npm
Version published
Weekly downloads
921
32.71%
Maintainers
1
Weekly downloads
 
Created
Source

#aTemplate.js

Simple Template Engine used for gulp-generator

##example

<!DOCTYPE html>
<html lang="ja">
<head>
	<meta charset="UTF-8">
	<title>list sample</title>
</head>
<body>
	<script id="list_template" type="text/template">
	<ul>
		<li><input type="text" data-bind="newItem"><button data-action="addItem()">追加</button></li>
		<!-- BEGIN list:loop -->
		<li>{name}[addMr]<button data-action="removeItem({i})">削除</button></li>
		<!-- END list:loop -->
	</ul>
	</script>
	<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
	<script src="../aTemplate.js"></script>
	<script>
	var list = new aTemplate.View({
		templates:["list_template"],
		data:{
			list:[
				{name:"tomomi"},
				{name:"daigo"},
				{name:"taro"},
				{name:"koike"}
			]
		},
		method:{
			removeItem:function(i){
				this.data.list.splice(i,1);
				this.update();
			},
			addItem:function(){
				console.log(this.data.newItem);
				this.data.list.push({name:this.data.newItem});
				this.update();
			}
		},
		convert:{
			addMr:function($txt){
				return "Mr."+$txt;
			}
		}
	});
	list.update();
	</script>
</body>
</html>

FAQs

Package last updated on 15 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts