Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 9c590ea

Browse files
committed
first commit
0 parents  commit 9c590ea

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
3+
#ide
4+
.idea
5+
/*.iml

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Vasily Ostanin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ejs-compiled-loader for webpack
2+
3+
EJS loader for [webpack](http://webpack.github.io/). Uses [ejs](https://github.com/tj/ejs) function to compile templates.
4+
5+
## Installation
6+
7+
`npm install ejs-compiled-loader`
8+
9+
## Usage
10+
11+
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
12+
13+
``` javascript
14+
var template = require("ejs-compiled!./file.ejs");
15+
// => returns the template function compiled with ejs templating engine.
16+
17+
// And then use it somewhere in your code
18+
template(data) // Pass object with data
19+
```
20+
21+
## License
22+
23+
MIT (http://www.opensource.org/licenses/mit-license.php)
24+
25+
26+

index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var ejs = require('ejs'),
2+
uglify = require('uglify-js');
3+
4+
5+
module.exports = function (source) {
6+
this.cacheable && this.cacheable();
7+
var template = ejs.compile(source, {
8+
client: true
9+
});
10+
11+
var ast = uglify.parser.parse(template.toString());
12+
13+
return 'module.exports = ' + uglify.uglify.gen_code(ast, {beautify: true});
14+
};

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "ejs-compilated-loader",
3+
"version": "0.1.0",
4+
"description": "EJS webpack loader (without frontend dependencies)",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/bazilio91/ejs-compilated-loader.git"
12+
},
13+
"keywords": [
14+
"ejs",
15+
"webpack",
16+
"loader",
17+
"template"
18+
],
19+
"author": "Vasily Ostanin <[email protected]>",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/bazilio91/ejs-compilated-loader/issues"
23+
},
24+
"homepage": "https://github.com/bazilio91/ejs-compilated-loader",
25+
"dependencies": {
26+
"ejs": "^1.0.0",
27+
"uglify-js": "~1.3.4"
28+
}
29+
}

0 commit comments

Comments
 (0)