HenrikJoreteg/templatizer — pull request #58 by ninov (2014-06-15 18:23:21+00:00)
Title: Add option "ignoreExtends"

This change will add the option "ignoreExtends".

When this option is set to a array of jade files, these files will be ignored, when they are extended.

This way you can use layout files server-side, but don't use them client-side, because you only want the important part of the template there, e.g. to inject it with JS.

Example:
--------
*views/layout.jade*

doctype html
html
head
title Test
body
h1 Test
nav#main-nav
li
a(href="fu.html") Fu
li
a(href="bar.html") Bar

#content
block content

footer#main-footer
p © Example Inc. 2014

*views/index.jade*

extends layout.jade
block content
p Welcome to my wonderful jade-driven website.

*app.js*

var templatizer = require("templatizer");
templatizer(__dirname + "/views", __dirname + "/static/js/views.js", {ignoreExtends: ["layout.jade"]});

=> *static/js/views.js*

// ...
// index.jade compiled template
templatizer["index"] = function tmpl_index() {
return "

Welcome to my wonderful jade-driven website.

";
};

// layout.jade compiled template
templatizer["layout"] = function tmpl_layout() {
return '

Test

Test

Fu
Bar

© Example Inc. 2014

';
};
// ...

*static/js/views.js* without `ignoreExtends`:

// index.jade compiled template
templatizer["index"] = function tmpl_index() {
return '

Test

Test

Fu
Bar

Welcome to my wonderful jade-driven website.

© Example Inc. 2014

';
};

// layout.jade compiled template
templatizer["layout"] = function tmpl_layout() {
return '

Test

Test

Fu
Bar

© Example Inc. 2014

';
};