Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/d-band/etpl-loader

Ejs template loader using babel.
https://github.com/d-band/etpl-loader

babel ejs encode loader webpack webpack-loader xss

Last synced: about 1 month ago
JSON representation

Ejs template loader using babel.

Awesome Lists containing this project

README

        

etpl-loader
===========

[![NPM version](https://img.shields.io/npm/v/etpl-loader.svg)](https://www.npmjs.com/package/etpl-loader)
[![NPM downloads](https://img.shields.io/npm/dm/etpl-loader.svg)](https://www.npmjs.com/package/etpl-loader)
[![Build Status](https://travis-ci.org/d-band/etpl-loader.svg?branch=master)](https://travis-ci.org/d-band/etpl-loader)
[![Coverage Status](https://coveralls.io/repos/github/d-band/etpl-loader/badge.svg?branch=master)](https://coveralls.io/github/d-band/etpl-loader?branch=master)
[![Dependency Status](https://david-dm.org/d-band/etpl-loader.svg)](https://david-dm.org/d-band/etpl-loader)

## Install

```
npm i etpl-loader -S
```

## Usage

**index.tpl**
```ejs

<%=name%>


<%=email%>



    <%for (var i=0; i
  • <%-skill%>

  • <%}%>


<%projects.forEach((project) => {%>

<%-project.name%>


<%=project.description%>



<%});%>

<%include('footer.tpl')%>
```

**footer.tpl**
```ejs

Copyright © <%=site.year%> <%=site.name%>. All Rights Reserved.

```

**index.js**
```js
import tpl from './index.tpl';

window.ENCODE = (str) => {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(//g, '>');
};

document.getElementById('root').innerHTML = tpl({
name: 'hello',
email: '[email protected]',
skills: [
'JavaScript',
'Java',
'C++',
'Go'
],
projects: [{
name: 'etpl-loader',
description: 'Ejs template webpack loader.'
}, {
name: 'dool',
description: 'Build tool based on webpack.'
}, {
name: 'yax',
description: 'Yet another store using redux.'
}],
site: {
name: 'D-Band',
year: '2018'
}
});
```

**webpack.config.js**
```js
module.exports = {
module: {
rules: [{
test: /\.tpl$/,
use: 'etpl-loader'
}]
}
}
```

## Options

|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`globals`**|`{Array}`|`['window', 'console']`|Global variables|
|**`encode`**|`{String}`|`'ENCODE'`|Encode function name|

## Report a issue

* [All issues](https://github.com/d-band/etpl-loader/issues)
* [New issue](https://github.com/d-band/etpl-loader/issues/new)

## License

etpl-loader is available under the terms of the MIT License.