Skip to content

Commit

Permalink
Merge pull request #2 from akim-mcmath/next
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
mcmath committed Jun 9, 2016
2 parents 6398db3 + 60e877a commit f5df528
Show file tree
Hide file tree
Showing 57 changed files with 315 additions and 475 deletions.
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
"es2015"
],
"plugins": [
"add-module-exports"
]
}
7 changes: 7 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: eslint:recommended
parserOptions:
ecmaVersion: 6
sourceType: module
env:
node: true
mocha: true
16 changes: 5 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
.DS_Store
logs
*.log
pids
*.pid
*.seed
lib-cov
coverage
.lock-wscript
npm-debug.log*
node_modules
/coverage/
/lib/
/node_modules/
/npm-debug.log
.tmp
7 changes: 0 additions & 7 deletions .jscsrc

This file was deleted.

5 changes: 0 additions & 5 deletions .jshintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/coverage/
/src/
/test/
/.babelrc
/.editorconfig
/.eslintrc.yml
/.gitignore
/.travis.yml
26 changes: 19 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
language: node_js
node_js:
- "stable"
- "5.0"
- "4.0"
- "6"
- "5"
- "4"
- "0.12"
- "0.10"
after_script:
after_success:
- npm run coveralls
branches:
only:
- master
before_deploy:
- npm run build
deploy:
provider: npm
email:
secure: E1X0Di6u1dhOXAvEsGXTTMZzz0Cx7RqNS9O4U5Tgdqlqaq9maDoHz8rZNHwqcx97m6DkgH4/go+D22DARLPr7Y+5XJNBrFcDKWPbU34lBHsTjwhxnuoKS8h7VZ/lGvQqPp1ircyYvsG5rd97J4z0hI27gF3Sj9tk8W3bn3ZTc8JxIoEw00aiEC7KNNnDpO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I4Ui9vNvjaD2VG4Qa7HtsUNi342/uaVnRMf24/VI/UOkhgI8e2DDKH35RucLK0sxrEEUfTwqNM2jhBuNQHA+BDpyAg=
skip_cleanup: true
on:
repo: akim-mcmath/ejs-html-loader
node: "4"
tags: true
after_deploy:
- npm run unbuild
76 changes: 0 additions & 76 deletions CHANGELOG.md

This file was deleted.

File renamed without changes.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,38 @@
[![Coverage][coverage-badge]][coveralls]
[![Dependencies][dependencies-badge]][gemnasium]

A [Webpack][webpack] loader for rendering plain HTML from [EJS][ejs]
template files.
[Webpack][webpack] loader for rendering plain HTML from [EJS][ejs]
template files

## Install

Install via [npm][npm]:
Install with [npm][npm]. And be sure to install [EJS][ejs] and
[Webpack][webpack], which are peer dependencies.

```sh
npm install --save-dev ejs-html-loader
npm install --save-dev webpack ejs ejs-html-loader
```

## Usage

Options and locals may be set via query string or query object:
In your Webpack [configuration][webpack-configuration], options and locals can
be passed to EJS in two ways. First, through a query string or query object:

```js
// webpack.config.js

module.exports = {
// ...
module: {
loaders: [
{
test: /\.ejs$/,
loader: 'ejs-html?title=The%20Big%20Gatsby&production'
}
]
loaders: [{
test: /\.ejs$/,
loader: 'ejs-html?title=The%20Big%20Gatsby&production'
}]
}
};
```

Or they may be set in the `ejsHtml` or `ejsHtmlLoader` property of your
Webpack configuration:
Or second, via an `'ejsHtml'` property:

```js
// webpack.config.js

module.exports = {
// ...
ejsHtml: {
Expand Down Expand Up @@ -88,9 +83,10 @@ Copyright © 2016 Akim McMath. Licensed under the [MIT License][license].
[dependencies-badge]: https://img.shields.io/gemnasium/akim-mcmath/ejs-html-loader.svg?style=flat-square

[npm]: https://www.npmjs.com/package/ejs-html-loader
[license]: LICENSE.txt
[license]: LICENSE
[travis]: https://travis-ci.org/akim-mcmath/ejs-html-loader
[coveralls]: https://coveralls.io/github/akim-mcmath/ejs-html-loader?branch=master
[gemnasium]: https://gemnasium.com/akim-mcmath/ejs-html-loader
[webpack]: https://webpack.github.io/
[webpack-configuration]: https://webpack.github.io/docs/configuration.html
[ejs]: http://ejs.co/
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

28 changes: 0 additions & 28 deletions lib/dependencies.js

This file was deleted.

37 changes: 0 additions & 37 deletions lib/ejs-html-loader.js

This file was deleted.

49 changes: 24 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
{
"name": "ejs-html-loader",
"version": "1.2.2",
"version": "2.0.0",
"description": "Webpack loader for rendering HTML from EJS templates",
"main": "index.js",
"files": [
"lib",
"index.js",
"README.md",
"LICENSE.txt"
],
"main": "lib/index.js",
"scripts": {
"test": "npm run jshint && npm run jscs && npm run mocha",
"jshint": "jshint . --exclude-path .gitignore",
"jscs": "jscs .",
"mocha": "istanbul cover _mocha",
"clean": "rm -rf ./node_modules ./coverage",
"coverage": "npm test && open ./coverage/lcov-report/index.html",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"preversion": "npm run test"
"build": "npm run unbuild && babel src -d lib",
"unbuild": "rimraf lib",
"test:lint": "eslint lib test",
"test:unit": "istanbul cover _mocha -- test/index.coffee",
"test:report": "npm run test:unit && open coverage/lcov-report/index.html",
"test": "npm run test:lint && npm run test:unit",
"coveralls": "cat coverage/lcov.info | coveralls"
},
"engines": {
"node": ">=0.10"
Expand All @@ -42,21 +35,27 @@
},
"homepage": "https://github.com/akim-mcmath/ejs-html-loader#readme",
"peerDependencies": {
"webpack": "1.x - 2.x"
"webpack": "1.x - 2.x",
"ejs": "2.x"
},
"dependencies": {
"ejs": "^2.0.2",
"loader-utils": "^0.2.0"
"loader-utils": "^0.2.15"
},
"devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"bluebird": "^3.4.0",
"chai": "^3.5.0",
"coveralls": "^2.11.6",
"coffee-script": "^1.10.0",
"coveralls": "^2.11.9",
"ejs": "^2.4.2",
"eslint": "^2.11.1",
"file-loader": "^0.8.5",
"istanbul": "^0.4.2",
"jscs": "^2.9.0",
"jshint": "^2.9.1",
"mocha": "^2.4.5",
"rimraf": "^2.5.1",
"istanbul": "1.0.0-alpha.2",
"mocha": "^2.5.3",
"relative-path-map": "^1.0.1",
"rimraf": "^2.5.2",
"webpack": "^1.12.13"
}
}
24 changes: 24 additions & 0 deletions src/cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const cache = {};

export function addDependencies(ctx) {
add(ctx, get(ctx));
}

export function saveDependencies(ctx, deps) {
add(ctx, save(ctx, deps));
}

function get(ctx) {
return cache[ctx.resourcePath] || [];
}

function save(ctx, deps=[]) {
cache[ctx.resourcePath] = deps;
return get(ctx);
}

function add(ctx, deps) {
deps.forEach(name => {
ctx.addDependency(name);
});
}
Loading

0 comments on commit f5df528

Please sign in to comment.