Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/d-band/etpl-loader
- Owner: d-band
- Created: 2018-11-02T17:13:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:20:41.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T03:17:11.067Z (8 months ago)
- Topics: babel, ejs, encode, loader, webpack, webpack-loader, xss
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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%>
- <%-skill%>
<%for (var i=0; i
<%}%>
<%projects.forEach((project) => {%>
<%-project.name%>
<%=project.description%>
<%});%>
<%include('footer.tpl')%>
```
**footer.tpl**
```ejs
```
**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.