grunt-bake
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -357,2 +357,20 @@ /* | ||
keep_undefined_vars: { | ||
options: { | ||
content: { | ||
defined: "Hallo Welt!" | ||
}, | ||
transforms: { | ||
upper: function( string ) { | ||
return String( string ).toUpperCase(); | ||
} | ||
}, | ||
removeUndefined: false | ||
}, | ||
files: { | ||
"tmp/keep_undefined_vars.html": "test/fixtures/keep_undefined_vars.html" | ||
} | ||
}, | ||
multiline_bake: { | ||
@@ -359,0 +377,0 @@ files: { |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -182,2 +182,10 @@ # grunt-bake | ||
#### options.removeUndefined | ||
Type: `Bool` | ||
Default value: `true` | ||
Set to `false`, placeholders that could not be resolved (= no matching key in `content`) will be kept untouched in the output. | ||
### Usage Examples | ||
@@ -317,3 +325,3 @@ | ||
Alternativly, `_if` suppoerts two operators. the `==` and the `=!` operator. This allows to specify the name of the value and the content in single quotes, if the content is a string. | ||
Alternativly, `_if` suppoerts two operators. the `==` and the `!=` operator. This allows to specify the name of the value and the content in single quotes, if the content is a string. | ||
__Note: This is a simple implementation of the equals operator and is based solely on strings.__ | ||
@@ -320,0 +328,0 @@ |
@@ -30,3 +30,4 @@ /* | ||
parsePattern: /\{\{\s*([^\}]+)\s*\}\}/g, | ||
transformGutter: "|" | ||
transformGutter: "|", | ||
removeUndefined: true | ||
} ); | ||
@@ -70,2 +71,9 @@ | ||
// check if key exists and leave pattern untouched if specified in options | ||
// due to support for vairables as array keys (see #41) we need to check if we could resolve | ||
// something, because mout.object.has() can not resolve keys. | ||
if( resolved === "" && !mout.object.has( content, key ) && !options.removeUndefined ) { | ||
return match; | ||
} | ||
return transforms.reduce( applyTransform, resolved ); | ||
@@ -72,0 +80,0 @@ } ); |
@@ -35,3 +35,4 @@ "use strict"; | ||
"tmp/multiline_bake.html": "test/expected/multiline_bake.html", | ||
"tmp/var_as_array_key.html": "test/expected/var_as_array_key.html" | ||
"tmp/var_as_array_key.html": "test/expected/var_as_array_key.html", | ||
"tmp/keep_undefined_vars.html": "test/expected/keep_undefined_vars.html" | ||
}; | ||
@@ -38,0 +39,0 @@ |
49977
70
826
598