Adds Jade static pages support to brunch.
This plugin compile Jade templates into their HTML representation and create separate file for each input source file without wrapping it in AMD/CommonJS modules.
Install the plugin via npm with npm install --save jade-pages-brunch
.
Or, do manual install:
- Add
"jade-pages-brunch": "x.y.z"
topackage.json
of your brunch app. - If you want to use git version of plugin, add
"jade-pages-brunch": "git+https://github.com/Kagami/jade-pages-brunch.git"
.
Plugin settings could be defined in the plugins.jadePages
section of the brunch config. Defaults are:
exports.config =
...
plugins:
jadePages:
destination: (path) ->
path.replace /^app[\/\\](.*)\.jade$/, "$1.html"
jade:
doctype: "html"
htmlmin: false
You could compile only certian Jade pages by specifying pattern
option. By default all files with jade
extension are compiled.
Example:
exports.config =
...
plugins:
jadePages:
pattern: /^app\/pages\/.*\.jade$/
You could specify custom place for compiled Jade pages via destination
option. It should be Function which takes path of the source file and return destination file path String (relative to the public path). All intermediate directories in the path are created automatically.
By default all Jade pages in app/
are compiled to public/
with the same directory structure and have html
extension.
You could specify Jade options and template locals in the jade
and jade.locals
sections accordingly. Example:
exports.config =
...
plugins:
jadePages:
jade:
doctype: "xml"
pretty: true
locals:
varname: "123"
You could specify Jade filters in the filters
section. Example:
exports.config =
...
plugins:
jadePages:
filters:
php: (text) -> '<?php \n' + text + '\n?>'
destination: (path) ->
path.replace /^app[\/\\](.*)\.jade$/, "$1"
test.php.jade
:
:php
// ...
$answer = 42;
// ...
doctype html
html(lang="de")
body
p It's <?= $answer ?>!
Output (test.php
):
<?php
// ...
$answer = 42;
// ...
?>
<!DOCTYPE html>
<html lang="de">
<body>
<p>It's <?= $answer ?>!</p>
</body>
</html>
You could minify compiled templates using html-minifier by passing following values to the htmlmin
section:
- Enable with default options with
true
. Default options are:
removeComments: true
removeCommentsFromCDATA: true
removeCDATASectionsFromCDATA: true
collapseBooleanAttributes: true
useShortDoctype: true
removeEmptyAttributes: true
removeScriptTypeAttributes: true
removeStyleLinkTypeAttributes: true
- Specify custom options by passing Object; see options description here.
Note that by default HTML minification is disabled and using minification with agressive options could break things.
Example:
exports.config =
...
plugins:
jadePages:
htmlmin:
removeComments: true
collapseWhitespace: true
removeEmptyAttributes: true
Because static-jade-brunch and jaded-brunch don't compatible with another plugin which I use, jade-ngtemplates-brunch. They are both using templates
brunch option and enter into a conflict with each other.
And I don't want to implement jade-pages functionality as a part of jade-ngtemplates-brunch (like it was done for example in jade-angularjs-brunch) because it contradicts with plugins modularity spirit.
Unfortunately Brunch doesn't provide a lot of flexibility for plugins. From it's point of view templates are always compiled into single JS file so we need to hack it out and write resulting compiled pages by ourself. Since we did it, another plugin wouldn't make any sense.
In this issue goes discussion about Brunch architecture improvements but no real progress is done for now.
jade-pages-brunch - Adds Jade static pages support to brunch
Written in 2014 by Kagami Hiiragi [email protected]
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.