grunt-bake
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -196,2 +196,19 @@ /* | ||
} | ||
}, | ||
section_bake: { | ||
options: { | ||
content: { | ||
home: { | ||
title: "Home" | ||
}, | ||
about: { | ||
title: "About" | ||
} | ||
} | ||
}, | ||
files: { | ||
"tmp/section_bake.html": "test/fixtures/section_bake.html" | ||
} | ||
} | ||
@@ -198,0 +215,0 @@ } |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -389,2 +389,49 @@ # grunt-bake [![Build Status](https://travis-ci.org/MathiasPaumgarten/grunt-bake.png?branch=master)](https://travis-ci.org/MathiasPaumgarten/grunt-bake) | ||
#### Inline Section statement | ||
The `_section` attribute, when used inline, allows to use a specific subcontent of the values. | ||
_app/base.html_: | ||
```html | ||
<html> | ||
<body> | ||
<!--(bake includes/file.html _section="home")--> | ||
<!--(bake includes/file.html _section="about")--> | ||
</body> | ||
</html> | ||
``` | ||
_app/includes/file.html_: | ||
```html | ||
<h1>{{title}}</h1> | ||
<p>{{content}}</p> | ||
``` | ||
With the following content file | ||
```json | ||
{ | ||
"home": { | ||
"title": "Home", | ||
"content": "This is home" | ||
}, | ||
"about": { | ||
"title": "About", | ||
"content": "This is about" | ||
} | ||
} | ||
``` | ||
This will render the following: | ||
```html | ||
<html> | ||
<body> | ||
<h1>Home</h1> | ||
<p>This is home</p> | ||
<h1>About</h1> | ||
<p>This is about</p> | ||
</body> | ||
</html> | ||
``` | ||
#### Costum process | ||
@@ -391,0 +438,0 @@ This example shows the use of a costum process funtion. |
@@ -172,2 +172,17 @@ /* | ||
// Handle _section attributes in inline arguments | ||
function validateSection( inlineValues ) { | ||
if ( "_section" in inlineValues ) { | ||
var value = inlineValues[ "_section" ]; | ||
delete inlineValues[ "_section" ]; | ||
return value; | ||
} | ||
return null; | ||
} | ||
// Handle _foreach attributes in inline arguments | ||
@@ -203,3 +218,8 @@ | ||
var inlineValues = parseInlineValues( attributes ); | ||
var section = validateSection( inlineValues, values ); | ||
if ( section !== null ) { | ||
values = values[ section ]; | ||
} | ||
if ( validateIf( inlineValues, values ) ) return ""; | ||
@@ -250,3 +270,8 @@ | ||
var includeContent = content.trimRight(); | ||
var section = validateSection( inlineValues, values ); | ||
if ( section !== null ) { | ||
values = values[ section ]; | ||
} | ||
values = mout.object.merge( values, inlineValues ); | ||
@@ -310,3 +335,2 @@ | ||
// Loop over files and create baked files. | ||
@@ -313,0 +337,0 @@ |
@@ -23,3 +23,4 @@ "use strict"; | ||
"tmp/no_process_bake.html": "test/expected/no_process_bake.html", | ||
"tmp/object_bake.html": "test/expected/object_bake.html" | ||
"tmp/object_bake.html": "test/expected/object_bake.html", | ||
"tmp/section_bake.html": "test/expected/section_bake.html" | ||
}; | ||
@@ -26,0 +27,0 @@ |
30662
43
476
473