grunt-bake
Advanced tools
Comparing version 1.5.0 to 1.5.1
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -562,3 +562,3 @@ # grunt-bake | ||
The following example will create two additional files named `info-John.html` and `info-Jane.html` which will be baked using `app/detail.html` with corresponding values from `app/content.json`. For linking to genereated files a `@link` variable is available. | ||
The following example will create two additional files named `info-John.html` and `info-Jane.html` which will be baked using `app/detail.html` with corresponding values from `app/content.json`. For linking to genereated files a `@link` variable is available. For linking the originating file from generated files a `@referrer` variable is available. | ||
@@ -571,2 +571,5 @@ _app/detail.html_: | ||
<p>I am a {{member.profession}}</p> | ||
<p> | ||
<a href="{{@referrer}}">Back to team</a> | ||
</p> | ||
</body> | ||
@@ -668,2 +671,3 @@ </html> | ||
`1.5.1` __2-9-2016__ adds @referrer attribute to _bake. | ||
`1.5.0` __2-2-2016__ adds support for _bake attribute. | ||
@@ -670,0 +674,0 @@ `1.4.1` __2-2-2016__ fixes minor bug fix #72. |
@@ -136,3 +136,2 @@ /* | ||
// Returns the directory path from a file path | ||
@@ -148,3 +147,10 @@ | ||
// Returns the filename from a file path | ||
function filename( path ) { | ||
var segments = path.split( "/" ); | ||
return segments.pop(); | ||
} | ||
// Parses attribute string. | ||
@@ -174,4 +180,4 @@ | ||
result = { | ||
includePath: match[1], | ||
attributes: match[2], | ||
includePath: match[ 1 ], | ||
attributes: match[ 2 ], | ||
signature: signature | ||
@@ -264,3 +270,3 @@ }; | ||
params[varname] = resolved; | ||
params[ varname ] = resolved; | ||
@@ -369,4 +375,14 @@ return "params['" + varname + "']"; | ||
// inject variable to link to dynamically processed file | ||
values[ "@link" ] = processContent( bake.dest, values ); | ||
// compute the depth of the destination path | ||
var parentDirsCount = bake.dest.split( "/" ).length - 1; | ||
// create a prefix for building a link to parent folder | ||
var parentDirsString = new Array( parentDirsCount + 1 ).join( "../" ); | ||
// inject variable to link to file that triggered the dynamic creation, from dynamically processed file | ||
values[ "@referrer" ] = parentDirsString + filename( destFile ); | ||
bakeFile( src, dest, values ); | ||
@@ -373,0 +389,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57872
893
675