grunt-contrib-jade
Advanced tools
Comparing version 0.2.0 to 0.3.0
12
grunt.js
@@ -47,12 +47,3 @@ /* | ||
'tmp/jade2.html': ['test/fixtures/jade2.jade'], | ||
'tmp/jadeInclude.html': ['test/fixtures/jadeInclude.jade'] | ||
}, | ||
options: { | ||
data: { | ||
test: true | ||
} | ||
} | ||
}, | ||
template: { | ||
files: { | ||
'tmp/jadeInclude.html': ['test/fixtures/jadeInclude.jade'], | ||
'tmp/jadeTemplate.html': ['test/fixtures/jadeTemplate.jade'] | ||
@@ -62,2 +53,3 @@ }, | ||
data: { | ||
test: true, | ||
year: '<%= grunt.template.today("yyyy") %>' | ||
@@ -64,0 +56,0 @@ } |
{ | ||
"name": "grunt-contrib-jade", | ||
"description": "Compile Jade files to HTML.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/gruntjs/grunt-contrib-jade", | ||
@@ -32,7 +32,7 @@ "author": { | ||
"jade": "~0.27.2", | ||
"grunt-contrib-lib": "~0.2.0" | ||
"grunt-contrib-lib": "~0.3.0" | ||
}, | ||
"devDependencies": { | ||
"grunt": "~0.3.15", | ||
"grunt-contrib-clean": "~0.2.0" | ||
"grunt-contrib-clean": "~0.3.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# grunt-contrib-jade | ||
# grunt-contrib-jade [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-jade.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-jade) | ||
> Compile Jade files to HTML (part of the [grunt-contrib](https://github.com/gruntjs/grunt-contrib) collection). Submitted by [Eric Woroshow](https://github.com/errcw). | ||
@@ -106,2 +106,6 @@ | ||
} | ||
``` | ||
``` | ||
## Release History | ||
* 2012/09/24 - v0.3.0 - general cleanup and consolidation. test refactoring. global options depreciated. | ||
* 2012/09/10 - v0.2.0 - refactored from grunt-contrib into individual repo. |
@@ -17,8 +17,8 @@ /* | ||
grunt.registerMultiTask('jade', 'Compile Jade templates into HTML.', function() { | ||
var _ = grunt.util._; | ||
var kindOf = grunt.util.kindOf; | ||
var helpers = require('grunt-contrib-lib').init(grunt); | ||
var options = helpers.options(this, {data: {}}); | ||
var options = helpers.options(this, { | ||
data: {} | ||
}); | ||
grunt.verbose.writeflags(options, 'Options'); | ||
@@ -29,15 +29,4 @@ | ||
var helperData = options.data; | ||
_.each(helperData, function(value, key) { | ||
if (kindOf(value) === 'string') { | ||
helperData[key] = grunt.template.process(value); | ||
} | ||
}); | ||
var srcFiles; | ||
var taskOutput; | ||
var sourceCode; | ||
var sourceCompiled; | ||
var helperOptions; | ||
@@ -50,8 +39,3 @@ this.files.forEach(function(file) { | ||
srcFiles.forEach(function(srcFile) { | ||
helperOptions = _.extend({filename: srcFile}, options); | ||
sourceCode = grunt.file.read(srcFile); | ||
sourceCompiled = compileJade(sourceCode, helperOptions, helperData); | ||
taskOutput.push(sourceCompiled); | ||
taskOutput.push(compileJade(srcFile, options, options.data)); | ||
}); | ||
@@ -61,3 +45,3 @@ | ||
grunt.file.write(file.dest, taskOutput.join('\n')); | ||
grunt.log.writeln('File ' + file.dest + ' created.'); | ||
grunt.log.writeln('File ' + file.dest.cyan + ' created.'); | ||
} | ||
@@ -67,5 +51,10 @@ }); | ||
var compileJade = function(src, options, data) { | ||
var compileJade = function(srcFile, options, data) { | ||
options = grunt.util._.extend({filename: srcFile}, options); | ||
delete options.data; | ||
var srcCode = grunt.file.read(srcFile); | ||
try { | ||
return require('jade').compile(src, options)(data); | ||
return require('jade').compile(srcCode, options)(data); | ||
} catch (e) { | ||
@@ -72,0 +61,0 @@ grunt.log.error(e); |
var grunt = require('grunt'); | ||
exports['jade'] = { | ||
main: function(test) { | ||
exports.jade = { | ||
compile: function(test) { | ||
'use strict'; | ||
var expect, result; | ||
test.expect(4); | ||
expect = '<div id="test" class="test"><span id="data">data</span><div>testing</div></div>'; | ||
result = grunt.file.read('tmp/jade.html'); | ||
test.equal(expect, result, 'should compile jade templates to html'); | ||
var actual = grunt.file.read('tmp/jade.html'); | ||
var expected = grunt.file.read('test/expected/jade.html'); | ||
test.equal(expected, actual, 'should compile jade templates to html'); | ||
expect = '<div id="test" class="test"><span id="data">data</span><div>testing 2</div></div>'; | ||
result = grunt.file.read('tmp/jade2.html'); | ||
test.equal(expect, result, 'should compile jade templates to html (multiple files support)'); | ||
actual = grunt.file.read('tmp/jade2.html'); | ||
expected = grunt.file.read('test/expected/jade2.html'); | ||
test.equal(expected, actual, 'should compile jade templates to html (multiple files support)'); | ||
expect = "<html><head><title>TEST</title></head><body></body></html><p>hello jade test</p>"; | ||
result = grunt.file.read("tmp/jadeInclude.html"); | ||
test.equal(expect, result, 'should compile jade templates to html with an include'); | ||
actual = grunt.file.read('tmp/jadeInclude.html'); | ||
expected = grunt.file.read('test/expected/jadeInclude.html'); | ||
test.equal(expected, actual, 'should compile jade templates to html with an include'); | ||
expect = '<div>' + grunt.template.today('yyyy') + '</div>'; | ||
result = grunt.file.read('tmp/jadeTemplate.html'); | ||
test.equal(expect, result, 'should compile jade templates to html with grunt template support'); | ||
actual = grunt.file.read('tmp/jadeTemplate.html'); | ||
expected = grunt.file.read('test/expected/jadeTemplate.html'); | ||
test.equal(expected, actual, 'should compile jade templates to html with grunt template support'); | ||
@@ -27,0 +25,0 @@ test.done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
110
9990
131
+ Addedgrunt-contrib-lib@0.3.0(transitive)
- Removedgrunt-contrib-lib@0.2.1(transitive)
Updatedgrunt-contrib-lib@~0.3.0