Skip to content

Commit

Permalink
Merge pull request #3 from legomind/master
Browse files Browse the repository at this point in the history
added ability to specify jade compile options
  • Loading branch information
dbashford committed Apr 7, 2014
2 parents b812033 + 352fef2 commit f08e9b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ This module utilizes all of the built-in template behavior that comes with Mimos
jade:
lib: undefined
extensions: [ "jade" ]
compileOptions:
compileDebug: false
```

* `lib`: You may want to use this module but may not be ready to use the latest version of Jade. Using the `lib` property you can provide a specific version of Jade if the one being used by this module isn't to your liking. To provide a specific version, you must have it `npm install`ed into your project and then provide it to `lib`. For instance: `lib: require('jade')`. To use a version of jade prior to `1.0`, use mimosa-jade `1.0.1`.
* `extensions`: an array of strings, the extensions of your Jade files.
* `compileOptions`: an object to be passed to `jade.compile`.
10 changes: 8 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
exports.defaults = function() {
return {
jade: {
extensions: [ "jade" ]
extensions: [ "jade" ],
compileOptions: {
compileDebug: false
}
}
};
};
Expand All @@ -12,13 +15,16 @@ exports.placeholder = function() {
return "\t\n\n" +
" jade: # config settings for the Jade compiler module\n" +
" lib: undefined # use this property to provide a specific version of Jade\n" +
" extensions: [\"jade\"] # default extensions for Jade files\n";
" extensions: [\"jade\"] # default extensions for Jade files\n" +
" compileOptions: #default jade compile options\n" +
" compileDebug: false\n";
};

exports.validate = function( config, validators ) {
var errors = [];

if ( validators.ifExistsIsObject( errors, "jade config", config.jade ) ) {
validators.ifExistsIsObject( errors, "jade compileOptions", config.jade.compileOptions )

if ( !config.jade.lib ) {
config.jade.lib = require( "jade" );
Expand Down
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ var compile = function ( mimosaConfig, file, cb ) {
var error, output;

try {
var opts = {
compileDebug: false,
filename: file.inputFileName
};
var opts = mimosaConfig.jade.compileOptions;
opts.filename = file.inputFileName;

output = mimosaConfig.jade.lib.compileClient( file.inputFileText, opts);
} catch ( err ) {
Expand Down

0 comments on commit f08e9b7

Please sign in to comment.