metalsmith / layouts

A metalsmith plugin for layouts
MIT License
116 stars 49 forks source link

Nunjucks: Specify default extends #71

Closed zslabs closed 8 years ago

zslabs commented 8 years ago

Nunjucks template inheritance works by specifying an extends tag, like {% extends 'default.html' %} at the top of the file. What makes this tricky with metalsmith-layouts is if I specify default: 'default.html' as one of the options, it automatically surrounds the content, but I can't hook into any blocks that have been specified in the extended template. Any thoughts on how I can do this?

ismay commented 8 years ago

That's not possible with metalsmith-layouts. Metalsmith-layouts has been created to allow you to use extends with templating languages that don't natively support it, like handlebars. So it doesn't process any templating syntax in the files in your src, but just applies the selected template.

If you want to process templating syntax in the files in src you can use metalsmith-in-place. It processes templating syntax in all files that you pass to it. You can either process all your templates with it (and omit metalsmith-layouts), or add it to your current build chain: metalsmith-in-place

ismay commented 8 years ago

See here for examples: metalsmith-in-place with extends

Let me know if you have any other questions!

zslabs commented 8 years ago

@ismay Thanks for the example!

ismay commented 8 years ago

:+1: No problem!