From 53cfd8107ea59722566945c170a0512bc47336d3 Mon Sep 17 00:00:00 2001 From: vladikoff Date: Fri, 11 Jul 2014 10:17:51 -0700 Subject: [PATCH] Dependency and doc updates. --- CHANGELOG | 5 +++++ Gruntfile.js | 2 +- README.md | 5 +++-- package.json | 11 +++++------ tasks/jst.js | 4 ++-- tasks/lib/jst.js | 18 ++++++++++++++++++ 6 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 tasks/lib/jst.js diff --git a/CHANGELOG b/CHANGELOG index 643885e..96d323a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +v0.6.0: + date: 2014-02-28 + changes: + - Bug fixes and dependency updates. + - Adds color log. v0.5.1: date: 2013-07-14 changes: diff --git a/Gruntfile.js b/Gruntfile.js index 258c5f9..4b0b81c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,7 @@ * grunt-contrib-jst * http://gruntjs.com/ * - * Copyright (c) 2014 Tim Branyen, contributors + * Copyright (c) 2014 Tim Branyen, contributors * Licensed under the MIT license. */ diff --git a/README.md b/README.md index 8273fa5..28f69c6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# grunt-contrib-jst v0.6.0 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-jst.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-jst) +# grunt-contrib-jst v0.7.0-pre [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-jst.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-jst) > Precompile Underscore templates to JST file. @@ -149,6 +149,7 @@ Note that the `interpolate: /\{\{(.+?)\}\}/g` setting above is simply an example ## Release History + * 2014-02-28   v0.6.0   Bug fixes and dependency updates. Adds color log. * 2013-07-14   v0.5.1   Display filepath when fails to compile. * 2013-03-06   v0.5.0   When `namespace` is false and `amd` is true, return templates directly from AMD wrapper. Rename `amdwrapper` option to `amd` to match grunt-contrib-handlebars. * 2013-02-15   v0.4.1   First official release for Grunt 0.4.0. @@ -165,4 +166,4 @@ Note that the `interpolate: /\{\{(.+?)\}\}/g` setting above is simply an example Task submitted by [Tim Branyen](http://tbranyen.com) -*This file was generated on Sat Mar 01 2014 03:29:46.* +*This file was generated on Fri Jul 11 2014 10:15:42.* diff --git a/package.json b/package.json index 5944b76..7e570b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-contrib-jst", "description": "Precompile Underscore templates to JST file.", - "version": "0.6.0", + "version": "0.7.0-pre", "homepage": "https://github.com/gruntjs/grunt-contrib-jst", "author": { "name": "Grunt Team", @@ -21,19 +21,18 @@ } ], "engines": { - "node": ">= 0.8.0" + "node": ">= 0.10.0" }, "scripts": { "test": "grunt test" }, "dependencies": { "lodash": "~2.4.1", - "grunt-lib-contrib": "~0.7.0", - "chalk": "~0.4.0" + "chalk": "~0.5.0" }, "devDependencies": { - "grunt-contrib-jshint": "~0.8.0", - "grunt-contrib-nodeunit": "~0.3.2", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-nodeunit": "~0.4.1", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-internal": "~0.4.5", "grunt": "~0.4.2" diff --git a/tasks/jst.js b/tasks/jst.js index 5311480..5721b92 100644 --- a/tasks/jst.js +++ b/tasks/jst.js @@ -16,7 +16,7 @@ module.exports = function(grunt) { grunt.registerMultiTask('jst', 'Compile underscore templates to JST file', function() { var lf = grunt.util.linefeed; - var helpers = require('grunt-lib-contrib').init(grunt); + var lib = require('./lib/jst'); var options = this.options({ namespace: 'JST', templateSettings: {}, @@ -29,7 +29,7 @@ module.exports = function(grunt) { var nsInfo; if (options.namespace !== false) { - nsInfo = helpers.getNamespaceDeclaration(options.namespace); + nsInfo = lib.getNamespaceDeclaration(options.namespace); } this.files.forEach(function(f) { diff --git a/tasks/lib/jst.js b/tasks/lib/jst.js new file mode 100644 index 0000000..8b6df2e --- /dev/null +++ b/tasks/lib/jst.js @@ -0,0 +1,18 @@ +exports.getNamespaceDeclaration = function(ns) { + var output = []; + var curPath = 'this'; + if (ns !== 'this') { + var nsParts = ns.split('.'); + nsParts.forEach(function(curPart, index) { + if (curPart !== 'this') { + curPath += '[' + JSON.stringify(curPart) + ']'; + output.push(curPath + ' = ' + curPath + ' || {};'); + } + }); + } + + return { + namespace: curPath, + declaration: output.join('\n') + }; +};