# light-tpl

> a lightweight JavaScript template engine

Latest version **1.0.3** (published 2019-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install light-tpl
pnpm add light-tpl
yarn add light-tpl
bun add light-tpl
```

## 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.3 |
| Published | 2019-08-29 |
| First published | 2019-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | fenghang |
| Maintainers | fenghang |
| Keywords | JavaScript, template, engine |

## Links

- npm: https://www.npmjs.com/package/light-tpl
- Repository: https://github.com/fh332393900/light-tpl
- Homepage: https://github.com/fh332393900/light-tpl#readme
- Issues: https://github.com/fh332393900/light-tpl/issues
- npm.io page: https://npm.io/package/light-tpl

## Recent versions

- 1.0.3 (latest) — 2019-08-29
- 1.0.2 — 2019-08-28
- 1.0.1 — 2019-08-28
- 1.0.0 — 2019-08-28

## README

# light-tpl
[![NPM version](https://img.shields.io/npm/v/light-tpl)](https://www.npmjs.com/package/light-tpl)
[![License MIT](https://img.shields.io/npm/l/light-tpl)](https://github.com/fh332393900/light-tpl/blob/master/LICENSE)
[![NPM size](https://img.shields.io/bundlephobia/min/light-tpl?color=orange)](https://www.npmjs.com/package/light-tpl)
[![NPM downloads](https://img.shields.io/npm/dw/light-tpl)](https://www.npmjs.com/package/light-tpl)


## How to use
You can use npm

    npm i light-tpl
    
Output the template as a function return value
```javascript
    let tpl = require('light-tpl')
    export default function myTest() {
        let data = [
            {name:"fenghang",phone:"17713605274",age:21},
            {name:"222",phone:"110",age:50}]
        let template = `
            <ul>
                <% for(var i=0; i < data.length; i++){
                    var item = data[i];
                    if(item.age < 30){%>
                        <li>我的名字是<%=item.name%>，我的年龄是<%=item.age%>,我的手机号：<%=item.phone%></li>
                    <%}else{%>
                        <li>my name is <%=item.name%>,my age is a sercet.</li>
                    <%}%>
                <% } %>
            </ul>`
        return tpl(template,data)
    }
```
result:
```html

        <ul>  
            <li>我的名字是fenghang，我的年龄是21,我的手机号：17713605274</li>
            <li>my name is 222,my age is a sercet.</li>
        </ul>
```
Rendered HTML:
* 我的名字是fenghang，我的年龄是21,我的手机号：17713605274
* my name is 222,my age is a sercet.

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