├── test
├── sample.jst
└── test-plugin-jst.js
├── .gitignore
├── .travis.yml
├── jst.js
├── .editorconfig
├── package.json
├── README.md
└── LICENSE
/test/sample.jst:
--------------------------------------------------------------------------------
1 |
<%=name%>
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | jspm_packages
3 | config.js
4 | sample.js
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | cache:
4 | directories:
5 | - node_modules
6 | node_js:
7 | - "0.10"
8 |
--------------------------------------------------------------------------------
/jst.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var _ = require('underscore');
4 |
5 | exports.translate = function (load) {
6 | return 'module.exports = ' + _.template(load.source).source + ';';
7 | };
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = tab
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 | indent_style = space
11 | indent_size = 2
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
15 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "plugin-jst",
3 | "version": "0.1.2",
4 | "description": "Underscore JST loader plugin",
5 | "main": "jst.js",
6 | "scripts": {
7 | "test": "mocha --compilers js:mocha-babel"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/podio/plugin-jst.git"
12 | },
13 | "keywords": [
14 | "jspm",
15 | "jst",
16 | "loader",
17 | "plugin"
18 | ],
19 | "author": "Albert Fernández ",
20 | "license": "MIT",
21 | "peerDependencies": {
22 | "underscore": "*"
23 | },
24 | "devDependencies": {
25 | "babel": "6.1.18",
26 | "babel-runtime": "6.3.19",
27 | "mocha": "2.3.4",
28 | "mocha-babel": "3.0.0",
29 | "systemjs": "0.19.17",
30 | "unexpected": "10.6.1",
31 | "underscore": "*"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jst
2 | ===========
3 |
4 | [](http://badge.fury.io/js/plugin-jst)
5 | [](https://travis-ci.org/podio/plugin-jst)
6 |
7 | SystemJS's underscore template `jst` loading plugin.
8 |
9 | ## How to use
10 |
11 | ```javascript
12 | import './sample.jst!'
13 | ```
14 |
15 | It requires to have `underscore` installed as a peer dependency, although you can also use it for `lodash` as long you alias it to `underscore` in your configuration, i.e.:
16 |
17 | ```javascript
18 | System.config({
19 | map: {
20 | underscore: 'lodash'
21 | }
22 | })
23 | ```
24 |
25 | ## Testing
26 |
27 | ```javascript
28 | $ npm install
29 | $ npm test
30 | ```
31 |
32 | ## License
33 |
34 | [MIT](https://github.com/podio/plugin-jst/blob/master/LICENSE)
35 |
--------------------------------------------------------------------------------
/test/test-plugin-jst.js:
--------------------------------------------------------------------------------
1 | let expect = require('unexpected');
2 | let System = require('systemjs');
3 |
4 | System.config({
5 | 'baseURL': '.',
6 | 'map': {
7 | 'jst': 'jst.js',
8 | 'underscore': './node_modules/underscore/underscore.js'
9 | }
10 | });
11 |
12 | describe('jst plugin', () => {
13 |
14 | it('should load jst template and return a function', () => {
15 | return System.import('test/sample.jst!').then((tpl) => {
16 | return expect(tpl, 'to be a function');
17 | });
18 | });
19 |
20 | it('should load jst template and return a function with arity 1', () => {
21 | return System.import('test/sample.jst!').then((tpl) => {
22 | return expect(tpl, 'to have arity', 1);
23 | });
24 | });
25 |
26 | it('should load jst template and translate it', () => {
27 | return System.import('test/sample.jst!').then((tpl) => {
28 | return expect(tpl({ name: 'hello world' }), 'to equal', 'hello world
\n');
29 | });
30 | });
31 |
32 | });
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Podio
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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------