# anima-template

> Anima template

Latest version **1.0.12** (published 2015-03-16) · 0 weekly downloads

## Install

```sh
npm install anima-template
pnpm add anima-template
yarn add anima-template
bun add anima-template
```

Provides the command `atpl`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2015-03-16 |
| First published | 2014-07-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yuanfei.gyf |
| Maintainers | yuanfei.gyf |
| Keywords | anima, template |

## Links

- npm: https://www.npmjs.com/package/anima-template
- Repository: https://gitlab.alibaba-inc.com/animajs/template
- Homepage: http://animajs.org/template/
- Issues: git://gitlab.alibaba-inc.com/animajs/template.git/issues
- npm.io page: https://npm.io/package/anima-template

## Dependencies (4)

- [nopt](https://npm.io/package/nopt.md) ^1.0.10
- [mkdirp](https://npm.io/package/mkdirp.md) 0.3.0
- [homunculus](https://npm.io/package/homunculus.md) ^0.5.3
- [js-beautify](https://npm.io/package/js-beautify.md) 1.5.4

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 1.0.12 (latest) — 2015-03-16
- 1.0.11 — 2015-03-16
- 1.0.10 — 2014-12-10
- 1.0.9 — 2014-10-29
- 1.0.8 — 2014-10-13
- 1.0.7 — 2014-09-19
- 1.0.6 — 2014-09-18
- 1.0.5 — 2014-09-18
- 1.0.4 — 2014-08-29
- 1.0.3 — 2014-08-06
- 1.0.2 — 2014-08-06
- 1.0.1 — 2014-07-18
- 1.0.0 — 2014-07-11

## README

# template

---

移动端模板引擎

---

## 实时编译

### 使用

````js
seajs.use('template', function(aTpl){

	aTpl(str, data);

	aTpl.compile(str).render(data);

	//aTpl(str)等同于aTpl.compile(str)
	//aTpl(str, data) 等同于 aTpl.compile(str).render(data)

})
````

### str `string`

模板id或原始模板字符串

````js

//左分割符为<%， 右分隔符为%>，暂不支持自定义
var str = 'I am <%=name%>';
//模板内支持JS逻辑,**不要在逻辑中声明out变量，内部使用**
var tpl =
		'<% if(name){ %>'+
			'I am <%=name%>' +
		'<% }else{ %>'+
			'Hello world !'+
		'<% } %>';

````

### data `object`

数据源

## 预编译

### **不要在模板函数中使用非数据源上的属性**

### 安装

```bash
$ npm install anima-template -g
```
#### 使用

```bash
$ atpl -o ./ template.tpl
```
### 参数说明

1. `atpl` 执行命令
2. `-o` `--outputdir` 输出文件夹（可选），默认是`./build`
3. `-v` `--version` 版本号
4. `-h` `--help` 帮助文档
5. `template.tpl` 原始模板文件（必选），支持`*.tpl`通配

### 模块使用

````js

var tpl = require('anima-template');

//str为模板字符串，result预编译后的结果
result = tpl(str)

````

### 应用

````js
//template.js为预编译后的文件
var tpl = require('template.js');

//tpl为编译后的函数，可直接使用
tpl(data)

````

---
_Source: https://npm.io/package/anima-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
