grunt-swig-it
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "grunt-swig-it", | ||
"description": "Create static HTML files using Swig", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/adamsilver/grunt-swig-it", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -28,13 +28,17 @@ # grunt-swig-it | ||
swig_it: { | ||
development: { | ||
init: { | ||
dev: { | ||
options: { | ||
swigDefaults: { | ||
allowErrors: false, | ||
autoescape: true | ||
}, | ||
test: { | ||
var: 'short path file' | ||
}, | ||
dest: "dest", | ||
src: ['src/swig/**/*.html'] | ||
} | ||
data: { | ||
foo: { | ||
bar: 'yeah' | ||
} | ||
} | ||
}, | ||
src: ['test/fixtures/**/*.html'], | ||
dest: "test/dest" | ||
} | ||
} | ||
@@ -44,6 +48,12 @@ }); | ||
For each template found within src swig-it will look for a json file of the same name to use as data for the template. | ||
The src directory should not include layout files so store 'pages' in a different folder to 'layouts' for your convenience. | ||
## Contributing | ||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). | ||
## Release History | ||
_(Nothing yet)_ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
grunt.registerMultiTask('swig_it', 'swig templater', function(tpl_context) { | ||
var options = this.options(); | ||
var config = this; | ||
@@ -15,10 +16,10 @@ var context = tpl_context || ''; | ||
if (config.data.init !== undefined) { | ||
swig.setDefaults(config.data.init); | ||
if (options.swigDefaults) { | ||
swig.setDefaults(options.swigDefaults); | ||
} | ||
try { | ||
globalVars = grunt.util._.extend(config.data, grunt.file.readJSON(process.cwd() + '/global.json')); | ||
globalVars = grunt.util._.extend(options.data, grunt.file.readJSON(process.cwd() + '/global.json')); | ||
} catch (err) { | ||
globalVars = grunt.util._.clone(config.data); | ||
globalVars = grunt.util._.clone(options.data); | ||
} | ||
@@ -47,7 +48,7 @@ | ||
try { | ||
contextVars = grunt.file.readJSON(path.dirname(file) + '/' + outputFile + "." + context + ".json"); | ||
} catch (err) { | ||
contextVars = {}; | ||
} | ||
// try { | ||
// contextVars = grunt.file.readJSON(path.dirname(file) + '/' + outputFile + "." + context + ".json"); | ||
// } catch (err) { | ||
// contextVars = {}; | ||
// } | ||
@@ -54,0 +55,0 @@ tplVars.context = context; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
49521
49
57
7