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

grunt-html-build

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-html-build - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

61

docs/options.md

@@ -17,3 +17,2 @@ # grunt-html-build

beautify: true,
basePath: false,
scripts: {

@@ -66,3 +65,3 @@ bundle: [

Additionnal Options
Additional Options

@@ -121,2 +120,37 @@ ### options.scripts, options.styles, options.sections

### options.prefix
**type :** string |
**optional** |
**default:** null
Append this prefix to all paths in script and style references.
### options.suffix
**type :** string, function |
**optional** |
**default:** null
Append this suffix to to CSS and JS files. Could be a `function(filename, url)` which return a string. The result will be appended to the URL in the form `{url}?{suffix}`
### options.relative
**type :** string |
**optional** |
**default:** true
Make generated path relative to dest path. If this arguments is specified with false value, generated paths will be written as you configure in your Gruntfile.
### options.replace
**type :** bool |
**optional** |
**default:** false
True to replace src file instead of creating a new file.
### options.keepTags
**type:** boolean |
**optional** |
**default:** false
True to keep `htmlbuild` special tags after HTML compilation.
### options.beautify

@@ -161,1 +195,24 @@ **type :** bool |

Log an alert in console if some optional tags are not rendered
### options.allowUnknownTags
**type :** bool |
**optional** |
**default:** false
Do not fail the task if the parser meet unknown tags.
Useful when working with `grunt-usemin`.
### options.parseTag
**type:** string |
**optional** |
**default:** 'build'
Specify the html-build tag name, default is 'build'.
Format : <!-- {options.parseTag}:{scripts|styles|sections|process|remove} {name} [attributes] -->
### options.EOL
**type:** string |
**optional** |
**default:** *autodectect*
Force output EOL. If not specified, it will be detected from the input file.

21

docs/process.md

@@ -35,13 +35,15 @@ # grunt-html-build

grunt.initConfig({
pkg = grunt.file.readJSON("package.json"),
pkg: grunt.file.readJSON("package.json"),
htmlbuild: {
src: 'index.html',
dest: 'dist/',
options: {
data: {
baseUrl: "http://my.prod.site.com/"
}
}
htmlbuild: {
dist: {
src: 'index.html',
dest: 'dist/',
options: {
data: {
baseUrl: "http://my.prod.site.com/"
}
}
}
}
});

@@ -70,2 +72,1 @@ ```

```

@@ -21,2 +21,5 @@ # grunt-html-build

<!-- /build -->
<!-- build:remove dev,test -->
<p class="prod-only"></p>
<!-- /build -->
</body>

@@ -31,4 +34,6 @@ </html>

htmlbuild: {
src: 'index.html',
dest: 'dist/'
dist: {
src: 'index.html',
dest: 'dist/'
}
}

@@ -48,2 +53,3 @@ });

<p> ... </p>
<p class="prod-only"></p>
</body>

@@ -53,1 +59,4 @@ </html>

### Per target
Note that __.prod-only__ is part is kept because we configured __remove__ task to remove this part only during __dev__ or __test__ target.

@@ -46,2 +46,2 @@ # grunt-html-build

</html>
```
```

@@ -13,4 +13,4 @@ # grunt-html-build

* libs
* lib1.html
* lib2.html
* lib1.js
* lib2.js
* css

@@ -33,3 +33,3 @@ * lib1.css

<!-- /build -->
<!-- build:style inline app -->
<!-- build:style inline app [media="screen and (max-width: 480px)"] -->
<link type="text/css" rel="stylesheet" href="/path/to/debug/app.css" />

@@ -47,2 +47,4 @@ <!-- /build -->

<!-- /build -->
<!-- build:script main [defer] -->
<!-- /build -->
<!-- build:script inline main -->

@@ -53,2 +55,8 @@ <script type="text/javascript">

<!-- /build -->
<!-- build:script inline noprocess main -->
<script type="text/javascript">
start();
</script>
<!-- /build -->
</body>

@@ -86,3 +94,2 @@ </html>

After grunt build, created index.html will contains links to files specified in options.
Moreover, some tags have the argument *inline* specified. It specify that this tags must render the content of files directly in the result HTML

@@ -94,3 +101,3 @@ ```html

<link type="text/css" rel="stylesheet" href="css/lib2.css" />
<style>
<style media="screen and (max-width: 480px)">
.content-of-app.css {}

@@ -104,5 +111,11 @@ </style>

<script type="text/javascript" src="app/module2.js"></script>
<script type="text/javascript" src="app/main.js" defer></script>
<script type="text/javascript">
// content of main.js
</script>
<script type="text/javascript">
// content of main.js without underscore templating.
// <%= %> tags will not be parsed.
// Useful when trying to include inlined version of lodash or underscore
</script>
</body>

@@ -112,1 +125,7 @@ </html>

### Tag options
* __optional__: Specifies that the tag can be omited from configuration. If not specified and no configuration exists for this particular tag. The task will fail.
* __inline__: Specifies that the tag must render the content of files directly in the resulting HTML.
* __noprocess__: Specifies that the tag content must not be processed by grunt.js templating engine. Must be used with __inline__.
* __[attributes]__: Specifies attributes that will be added to the resultings tags.

@@ -26,3 +26,3 @@ # grunt-html-build

<body>
<!-- build:section views --><!-- /build -->
<!-- build:section recursive views --><!-- /build -->
<!-- build:section templates --><!-- /build -->

@@ -50,4 +50,8 @@ </body>

After grunt build, created index.html will contains any files in views and tmpl directories.
After grunt build process the index.html file will contain files in views and template directories.
### Recursive option
If the __recursive__ option is specified in the tag, __grunt-html-build__ will recursively build every views passed in the section.
Useful to create a main layout file and cut your work in little files.
{
"name": "grunt-html-build",
"description": "Grunt HTML Builder - Appends scripts and styles, Removes debug parts, append html partials, Template options",
"version": "0.6.2",
"version": "0.7.0",
"homepage": "https://github.com/spatools/grunt-html-build.git",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -238,2 +238,7 @@ # grunt-html-build [![NPM version](https://badge.fury.io/js/grunt-html-build.png)](http://badge.fury.io/js/grunt-html-build)

* Optimize some code parts.
* Added option `basePath` allow keeping original folder structure
* Added option `basePath` allow keeping original folder structure.
* 0.6.2
* Fix some issues.
* 0.7.0
* Fix EOL inconsistent issue.
* Add suffix option to customize files query parameters (for cache).

@@ -32,3 +32,2 @@ /*

_ = require("lodash"),
EOL = grunt.util.linefeed,
URL = require("url"),

@@ -202,3 +201,3 @@ path = require("path"),

if (options.inline) {
var content = options.files.map(grunt.file.read).join(EOL);
var content = options.files.map(grunt.file.read).join(options.EOL);
return processHtmlTagTemplate(options, content);

@@ -210,3 +209,3 @@ }

return options.files.map(function (f) {
var url = (options.relative && !/^((http|https):)?(\\|\/\/)/.test(f) ) ? path.relative(destDir, f) : f;
var url = (options.relative && !/^((http|https):)?(\\|\/\/)/.test(f)) ? path.relative(destDir, f) : f;
url = url.replace(/\\/g, "/");

@@ -218,4 +217,14 @@

if (options.suffix) {
var suffix = typeof options.suffix === "function" ?
options.suffix(f, url) :
options.suffix;
if (suffix) {
url += "?" + suffix;
}
}
return processHtmlTagTemplate(options, url);
}).join(EOL);
}).join(options.EOL);
}

@@ -262,3 +271,3 @@ }

content;
}).join(EOL);
}).join(options.EOL);
},

@@ -269,3 +278,3 @@

.map(function (l) { return processTemplate(l, options); })
.join(EOL)
.join(options.EOL)
.replace(new RegExp(regexTagStart), "")

@@ -279,3 +288,3 @@ .replace(new RegExp(regexTagEnd), "");

if (targets.indexOf(grunt.task.current.target) < 0) {
return options.lines.join(EOL).replace(new RegExp(regexTagStart), "").replace(new RegExp(regexTagEnd), "");
return options.lines.join(options.EOL).replace(new RegExp(regexTagStart), "").replace(new RegExp(regexTagEnd), "");
}

@@ -294,2 +303,11 @@

function ensureContent(content, params) {
if (!params.EOL) {
var match = content.match(/\r?\n/);
params.EOL = match ? match[0] : "\n";
}
return content.replace(/\r?\n/g, params.EOL);
}
function transformContent(content, params, dest) {

@@ -300,3 +318,3 @@ var tags = getBuildTags(content),

tags.forEach(function (tag) {
var raw = tag.lines.join(EOL),
var raw = tag.lines.join(params.EOL),
result = "", prefix = "", suffix = "",

@@ -311,3 +329,5 @@ tagFiles = validators.validate(tag, params);

prefix: params.prefix,
suffix: params.suffix,
relative: params.relative,
EOL: params.EOL,
params: params

@@ -389,3 +409,5 @@ });

content = transformContent(grunt.file.read(src), params, dest);
content = grunt.file.read(src);
content = ensureContent(content, params);
content = transformContent(content, params, dest);

@@ -392,0 +414,0 @@ // write the contents to destination

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