From 55196028f5334a2b82a314ba5ac5d775b2bd65b9 Mon Sep 17 00:00:00 2001 From: Dmitriy Kubyshkin Date: Mon, 15 Dec 2014 15:48:11 +0100 Subject: [PATCH] Initial commit. --- .npmignore | 25 +++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ index.js | 7 +++++++ package.json | 27 +++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) create mode 100644 .npmignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..da23d0d --- /dev/null +++ b/.npmignore @@ -0,0 +1,25 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Deployed apps should consider commenting this line out: +# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..785252b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Andrey Okonetchnikov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..561bf6a --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# ejs-loader for webpack + +EJS (Underscore/LoDash Templates) loader for [webpack](http://webpack.github.io/). Uses [lodash template](http://lodash.com/docs#template) function to compile templates. + +## Installation + +`npm install ejs-loader` + +## Usage + +[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html) + +``` javascript +var template = require("ejs!./file.ejs"); +// => returns the template function compiled with undesrcore (lodash) templating engine. + +// And then use it somewhere in your code +template(data) // Pass object with data +``` + +## License + +MIT (http://www.opensource.org/licenses/mit-license.php) + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..201cad7 --- /dev/null +++ b/index.js @@ -0,0 +1,7 @@ +var _ = require('underscore'); + +module.exports = function (source) { + this.cacheable && this.cacheable(); + var template = _.template(source); + return 'module.exports = ' + template; +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..b2f3d86 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "tpl-loader", + "version": "0.1.0", + "description": "Underscore Templates loader for webpack", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/grassator/tpl-loader.git" + }, + "keywords": [ + "ejs", + "underscrore", + "lodash", + "_", + "webpack", + "loader", + "template" + ], + "author": { + "name": "Dmitriy Kubyshkin", + "email": "dmitriy@kubyshkin.ru" + }, + "license": "MIT", + "peerDependencies": { + "lodash": "*" + } +}