grunt-bake
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -380,2 +380,3 @@ /* | ||
}, | ||
var_as_array_key: { | ||
@@ -407,3 +408,14 @@ options: { | ||
} | ||
} | ||
}, | ||
path_with_placeholder: { | ||
options: { | ||
content: { | ||
filename: "include-one" | ||
} | ||
}, | ||
files: { | ||
"tmp/path_with_placeholder.html": "test/fixtures/path_with_placeholder.html" | ||
} | ||
}, | ||
} | ||
@@ -410,0 +422,0 @@ } ); |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -576,3 +576,3 @@ # grunt-bake | ||
process: processFunction | ||
} | ||
}, | ||
@@ -599,1 +599,6 @@ files: { | ||
``` | ||
## Changelog | ||
`1.3.0` __1-13-2016__ adds support for parsing file paths in bake tag. |
@@ -110,3 +110,3 @@ /* | ||
var regex = /(\n?)([ \t]*)<!--\(\s?bake(-start|-end)?([^]*?)\)-->/; | ||
var regex = /(\n?)([ \t]*)<!--\(\s?bake(-start|-end)?([\S\s]*?)\)-->/; | ||
@@ -388,3 +388,7 @@ // Regex to parse attributes. | ||
function preparePath( includePath, filePath ) { | ||
function preparePath( includePath, filePath, values ) { | ||
// replace placeholders within the include path | ||
includePath = processContent( includePath, values ); | ||
if ( includePath[ 0 ] === "/" ) | ||
@@ -396,3 +400,3 @@ return options.basePath + includePath.substr( 1 ); | ||
function replaceFile( linebreak, indent, includePath, attributes, filePath, values ) { | ||
includePath = preparePath( includePath, filePath ); | ||
includePath = preparePath( includePath, filePath, values ); | ||
@@ -530,6 +534,11 @@ var includeContent = grunt.file.read( includePath ); | ||
return mout.lang.isFunction( options.process ) ? options.process( fileContent, values ) : fileContent; | ||
return processContent( fileContent, values ); | ||
} | ||
// Run process function if processor-function is defined | ||
function processContent( content, values ) { | ||
return mout.lang.isFunction( options.process ) ? options.process( content, values ) : content; | ||
} | ||
// ========== | ||
@@ -536,0 +545,0 @@ // -- BAKE -- |
@@ -36,3 +36,4 @@ "use strict"; | ||
"tmp/var_as_array_key.html": "test/expected/var_as_array_key.html", | ||
"tmp/keep_undefined_vars.html": "test/expected/keep_undefined_vars.html" | ||
"tmp/keep_undefined_vars.html": "test/expected/keep_undefined_vars.html", | ||
"tmp/path_with_placeholder.html": "test/expected/path_with_placeholder.html" | ||
}; | ||
@@ -39,0 +40,0 @@ |
50819
72
843
603