grunt-bake
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -537,2 +537,8 @@ /* | ||
} | ||
}, | ||
default_variables: { | ||
files: { | ||
"tmp/default_variables.html": "test/fixtures/default_variables.html" | ||
} | ||
} | ||
@@ -550,5 +556,21 @@ } | ||
grunt.registerTask( "test", [ "clean", "bake", "nodeunit" ] ); | ||
grunt.registerTask( "test", [ "clean", "setup", "bake", "nodeunit", "teardown" ] ); | ||
grunt.registerTask( "default", [ "jsonlint", "jshint", "test" ] ); | ||
// Stubbing methods for testing purposes. Because we are good little developers | ||
// we clean up after ourselves. | ||
var realDateNow; | ||
grunt.registerTask( "setup", function() { | ||
realDateNow = Date.now; | ||
Date.now = function() { | ||
return 123456789; | ||
}; | ||
} ); | ||
grunt.registerTask( "teardown", function() { | ||
Date.now = realDateNow; | ||
} ); | ||
}; |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -82,2 +82,24 @@ # grunt-bake | ||
Additionally to the content provided, __bake__ comes with a set of default values that are attached to a `__bake` object which gets injected to the user content. Even if no content is provided. | ||
```js | ||
__bake.filename // the file path tbeing baked | ||
__bake.srcFilename // same as __bake.filename | ||
__bake.destFilename // the file path it is being written to | ||
__bake.timestamp // a timestamp (milliseconds) at baking | ||
``` | ||
These can be especially usefull in combnation with [transforms](#optionstransforms). | ||
```html | ||
<html> | ||
<head></head> | ||
<body> | ||
<!--(bake-start)--> | ||
{{__bake.destFilename}} was written at {{__base.timestamp | parseDate }} | ||
<!--(bake-end)--> | ||
</body> | ||
</html> | ||
``` | ||
#### options.section | ||
@@ -738,2 +760,3 @@ Type: `String` | ||
* `1.8.0` __4-20-2016__ Adds permanent variables under `__bake`. | ||
* `1.7.2` __4-20-2016__ Resolves recursion issues in _process and _assign. | ||
@@ -740,0 +763,0 @@ * `1.7.1` __4-8-2016__ Fix for issue with _process. |
@@ -74,3 +74,3 @@ /* | ||
if( processed === undefined ) { | ||
if ( processed === undefined ) { | ||
processed = ( ! options.removeUndefined ? match : "" ); | ||
@@ -80,3 +80,3 @@ } | ||
return processed; | ||
}); | ||
} ); | ||
} | ||
@@ -194,5 +194,3 @@ | ||
function filename( path ) { | ||
var segments = path.split( "/" ); | ||
return segments.pop(); | ||
return path.split( "/" ).pop(); | ||
} | ||
@@ -320,2 +318,3 @@ | ||
/* jshint evil:true */ | ||
/* eslint-disable no-eval */ | ||
@@ -485,3 +484,3 @@ return ! eval( condition ); | ||
return processContent( value, values ); | ||
}); | ||
} ); | ||
@@ -502,3 +501,3 @@ if ( validateIf( inlineValues, values ) ) return ""; | ||
} else if( forEachName && forEachValues.length > 0 ) { | ||
} else if ( forEachName && forEachValues.length > 0 ) { | ||
@@ -509,2 +508,3 @@ var fragment = ""; | ||
forEachValues.forEach( function( value, index ) { | ||
@@ -587,4 +587,4 @@ values[ forEachName ] = value; | ||
depth += (result[ 3 ] === "-start"); | ||
depth -= (result[ 3 ] === "-end"); | ||
depth += ( result[ 3 ] === "-start" ); | ||
depth -= ( result[ 3 ] === "-end" ); | ||
@@ -659,5 +659,14 @@ if( depth === 0 ) { | ||
bakeFile( src, dest, options.content ); | ||
var content = mout.object.merge( options.content, { | ||
__bake: { | ||
filename: src, | ||
srcFilename: src, | ||
destFilename: dest, | ||
timestamp: Date.now() | ||
} | ||
} ); | ||
bakeFile( src, dest, content ); | ||
} ); | ||
} ); | ||
}; |
@@ -50,3 +50,4 @@ "use strict"; | ||
"tmp/assign_bake.html": "test/expected/assign_bake.html", | ||
"tmp/inline_no_process.html": "test/expected/inline_no_process.html" | ||
"tmp/inline_no_process.html": "test/expected/inline_no_process.html", | ||
"tmp/default_variables.html": "test/expected/default_variables.html" | ||
}; | ||
@@ -53,0 +54,0 @@ |
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
68642
103
1051
774