New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-bake

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-bake - npm Package Compare versions

Comparing version 1.6.4 to 1.7.0

test/expected/assign_bake.html

12

Gruntfile.js

@@ -525,2 +525,14 @@ /*

}
},
assign_bake: {
files: {
"tmp/assign_bake.html": "test/fixtures/assign_bake.html"
}
},
inline_no_process: {
files: {
"tmp/inline_no_process.html": "test/fixtures/inline_no_process.html"
}
}

@@ -527,0 +539,0 @@ }

2

package.json
{
"name": "grunt-bake",
"description": "Bake external includes into files to create static pages with no server-side compilation time",
"version": "1.6.4",
"version": "1.7.0",
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake",

@@ -6,0 +6,0 @@ "author": {

@@ -562,2 +562,66 @@ # grunt-bake

#### Inline _assign statement
The `_assign` statement determines to save included content into a variable instead of placing it directly. The variables name is defined by `_assign`-value.
_app/base.html_:
```html
<html>
<body>
<!--(bake includes/file.html _assign="foo")-->
{{foo}}
<p>{{foo}}</p>
</body>
</html>
```
_app/includes/file.html_:
```html
<span>Hello World</span>
```
This will create:
_dist/index.html_:
```html
<html>
<body>
<span>Hello World</span>
<p><span>Hello World</span></p>
</body>
</html>
```
#### Inline _process statement
Set to `true` the `_process` statement prevents bake from processing the included files content. The include takes place, but neither placeholders become replaced nor further bake sections processed.
_app/base.html_:
```html
<html>
<body>
<!--(bake includes/file.html _process="false")-->
</body>
</html>
```
_app/includes/file.html_:
```html
<!--(bake includes/other.html)-->
<span>{{foo}}</span>
```
This will create:
_dist/index.html_:
```html
<html>
<body>
<!--(bake includes/other.html)-->
<span>{{foo}}</span>
</body>
</html>
```
#### Bake extra pages (e.g. detail pages)

@@ -674,2 +738,3 @@

* `1.7.0` __4-7-2016__ Adds _process and _assign attributes.
* `1.6.4` __4-4-2016__ Bug fixes.

@@ -676,0 +741,0 @@ * `1.6.3` __2-26-2016__ Allow inline section attribute to have multiple leves.

@@ -399,2 +399,30 @@ /*

// Handle _assign attributes in inline arguments
function validateAssign( inlineValues ) {
if ( "_assign" in inlineValues ) {
var value = inlineValues[ "_assign" ];
delete inlineValues[ "_assign" ];
return value;
}
return null;
}
// Handle _process attributes in inline arguments
function validateProcess( inlineValues ) {
if ( "_process" in inlineValues ) {
var value = inlineValues[ "_process" ];
delete inlineValues[ "_process" ];
return String(value).toLowerCase() === 'true' ;
}
return true;
}
function preparePath( includePath, filePath, values ) {

@@ -439,9 +467,12 @@

function replaceString( includeContent, linebreak, indent, includePath, attributes, filePath, destFile, values ) {
function replaceString( includeContent, linebreak, indent, includePath, attributes, filePath, destFile, parentValues ) {
var values = parentValues;
var inlineValues = parseInlineValues( attributes );
var section = validateSection( inlineValues, values );
var extraBake = validateBake( inlineValues );
var assign = validateAssign( inlineValues );
var doProcess = validateProcess( inlineValues );
if ( section !== null ) {
values = mout.object.get( values, section );
values = mout.object.get( parentValues, section );
}

@@ -456,3 +487,2 @@

if ( validateRender( inlineValues ) ) return "";
var forEachValues = [];

@@ -465,4 +495,9 @@ var forEachName = validateForEach( inlineValues, values, forEachValues );

if( forEachName && forEachValues.length > 0 ) {
var content = ""; // result of current bake-section
if( !doProcess ) {
content = linebreak + includeContent;
} else if( forEachName && forEachValues.length > 0 ) {
var fragment = "";

@@ -490,3 +525,3 @@ var oldValue = values[ forEachName ];

return fragment;
content = fragment;

@@ -497,8 +532,16 @@ } else if( !forEachName ) {

return linebreak + parse( includeContent, includePath, destFile, values );
content = linebreak + parse( includeContent, includePath, destFile, values );
} else {
return "";
content = "";
}
if( assign !== null ) {
parentValues[ assign ] = mout.string.ltrim( content );
content = "";
}
return content;
}

@@ -505,0 +548,0 @@

@@ -48,3 +48,5 @@ "use strict";

"tmp/extra-0-a-team.html": "test/expected/extra/extra-0-a-team.html",
"tmp/extra-1-b-team.html": "test/expected/extra/extra-1-b-team.html"
"tmp/extra-1-b-team.html": "test/expected/extra/extra-1-b-team.html",
"tmp/assign_bake.html": "test/expected/assign_bake.html",
"tmp/inline_no_process.html": "test/expected/inline_no_process.html"
};

@@ -51,0 +53,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc