grunt-bake
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -112,2 +112,8 @@ /* | ||
} | ||
}, | ||
format_bake: { | ||
files: { | ||
"tmp/format_bake.html": "test/fixtures/format_bake.html" | ||
} | ||
} | ||
@@ -114,0 +120,0 @@ }, |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -342,2 +342,4 @@ # grunt-bake | ||
## Release History | ||
* 2013-06-11 v0.0.11 Preserves indentation to create prettier markup | ||
* 2013-06-07 v0.0.10 Adds IF statement | ||
* 2013-05-01 v0.0.9 Fixes default basePath | ||
@@ -344,0 +346,0 @@ * 2013-04-30 v0.0.8 Support for absolute paths and basePath |
@@ -48,3 +48,3 @@ /* | ||
var regex = /<!--\(\s?bake\s+([\w\/.-]+)\s?([^>]*)\)-->/g; | ||
var regex = /([ |\t]*)<!--\(\s?bake\s+([\w\/.-]+)\s?([^>]*)\)-->/g; | ||
@@ -137,2 +137,17 @@ | ||
// Helper method to apply indent | ||
var applyIndent = function( indent, content ) { | ||
if ( ! indent || indent.length < 1 ) return content; | ||
var lines = content.split( "\n" ); | ||
var prepedLines = lines.map( function( line ) { | ||
return indent + line; | ||
} ); | ||
return prepedLines.join( "\n" ); | ||
} | ||
// ===================== | ||
@@ -150,3 +165,3 @@ // -- RECURSIVE PARSE -- | ||
return fileContent.replace( regex, function( match, includePath, attributes ) { | ||
return fileContent.replace( regex, function( match, indent, includePath, attributes ) { | ||
@@ -165,13 +180,10 @@ var inlineOptions = parseInlineOptions( attributes ); | ||
if ( includePath.substr( 0, 1 ) === "/" ) { | ||
if ( includePath[ 0 ] === "/" ) { | ||
includePath = options.basePath + includePath.substr( 1 ); | ||
} else { | ||
includePath = directory( filePath ) + "/" + includePath; | ||
} | ||
var includeContent = grunt.file.read( includePath ); | ||
includeContent = applyIndent( indent, includeContent ); | ||
@@ -178,0 +190,0 @@ return parse( includeContent, includePath, values ); |
@@ -85,3 +85,13 @@ "use strict"; | ||
test.done(); | ||
}, | ||
formatBake: function( test ) { | ||
test.expect( 1 ); | ||
var actual = grunt.file.read( "tmp/format_bake.html" ); | ||
var expected = grunt.file.read( "test/expected/format_bake.html" ); | ||
test.equal( actual, expected, "format bake" ); | ||
test.done(); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
22898
32
342
348