Eleventy: How to pass template engine options?

Created on 15 Feb 2018  路  7Comments  路  Source: 11ty/eleventy

I'm trying to use eleventy with pug and would like to pass custom render options. I'm asking this because I can't even make it work, as I'd like to use includes with relative paths. Pug throws me this error:
Error: the "filename" option is required to use includes and extends with "relative" paths

bug

All 7 comments

Can you please provide the section of your code where you're trying to include something?

Looking at https://github.com/11ty/eleventy/blob/master/test/TemplateRenderPugTest.js I think there鈥檚 something to this. All of my tests are absolute.

Can you be more specific about what pieces of the API reference you鈥檇 like to be exposed? https://pugjs.org/api/reference.html

@kleinfreund Sure, I might even say it wasn't clear enough for me on how to structure my project and how to use includes and extends properly.

Here's my project structure:
image

This is my .eleventy.js file:
image

And I have a include section-card.pug inside the section-about.pug file for example.

The relevant error lines eleventy throws me back are:

Eleventy:Template Template.render is bypassing wrapping content in layouts for './src/views/includes/section-about.pug'. +17ms
  Eleventy:Template ./src/views/includes/section-about.pug renderContent() using pug +0ms

Problem writing eleventy templates: 
Error: the "filename" option is required to use includes and extends with "relative" paths

@zachleat I do believe for this case I would need the filename option.

This will be included with Eleventy 0.2.15! Support and tests added 馃憤

New Pug features are doc鈥檇 here: https://github.com/11ty/eleventy/#template-engine-features allows you to configure any pug compile/render options you want.

@cfviotti I should also note (confusingly enough and frustratingly probably too late to change) that includes is relative to your input directory and not the current directory.

So it鈥檚 looking for includes in src/views/src/views/includes there.

@cfviotti I filed an improvement to this in #67.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamrelian picture jamrelian  路  3Comments

ndaidong picture ndaidong  路  4Comments

michrome picture michrome  路  3Comments

proog picture proog  路  3Comments

veleek picture veleek  路  3Comments