Skip to content

Commit

Permalink
Automatically extend sample layout when rendering components
Browse files Browse the repository at this point in the history
Fixes #128
  • Loading branch information
thomastuts committed Feb 10, 2017
1 parent 413678b commit 8796227
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions content/templates/_components/example/example-1.jade
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
button.btn.btn-primary Primary button

+icon('example')
3 changes: 3 additions & 0 deletions core/templates/layouts/sample.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include ../mixins/icon

block content
5 changes: 4 additions & 1 deletion core/templates/locals.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function getDefaultLocals() {
if (!language || language === 'jade') {
return jadeMarkup;
} else if (language === 'html') {
return jade.compile(jadeMarkup, {
const indentedJadeMarkup = jadeMarkup.split('\n').map(line => `\t${line}`).join('\n');
const markupWithLayout = `extends /../core/templates/layouts/sample\n\nblock content\n${indentedJadeMarkup}`;

return jade.compile(markupWithLayout, {
pretty: true,
basedir: 'content',
filename: componentFileLocation
Expand Down

0 comments on commit 8796227

Please sign in to comment.