Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow includes directory to contain sub folders #72

Closed
paulrobertlloyd opened this issue Mar 2, 2018 · 6 comments
Closed

Allow includes directory to contain sub folders #72

paulrobertlloyd opened this issue Mar 2, 2018 · 6 comments
Labels
Milestone

Comments

@paulrobertlloyd
Copy link
Contributor

Hey Zach! Trying this out, as I’ve long hoped for a good-as-Jekyll-but-in-Node static site generator, and this project looks very promising. In attempting to convert my Jekyll site, have come across an issue where it would appear that includes can’t be organised in sub-directories.

For example, in a document I have: {% include form/contact %}

However, the following error suggests sub-directories are not recognised:

Failed to lookup form.liquid in: src/_includes.

Is this the case? If so, can I make a feature request to allow for the includes directory to contain sub-folders… or will that break things?

@zachleat
Copy link
Member

zachleat commented Mar 2, 2018

Hey @paulrobertlloyd! Well, that’s disappointing—sorry! I assume you’re sticking with Liquid syntax there? I know it works as expected in Nunjucks.

Note that there are a few minor differences between Ruby Liquid and the liquidjs library we’re using here (unfortunately). This looks to be one of them.

I’ve filed issues upstream with them in the past and they’ve been very good about fixing! See also harttle/liquidjs#51

I’ll plan on filing one for this a little later (or you can, if you want to beat me to it).

@zachleat
Copy link
Member

zachleat commented Mar 3, 2018

Filed in harttle/liquidjs#61

Thanks!

@zachleat
Copy link
Member

zachleat commented Mar 3, 2018

The other option we have here is to expose an API to configure liquid rendering options so that individual applications could override dynamicPartials to true. This would require that all includes paths be quoted as strings.

zachleat added a commit that referenced this issue Mar 3, 2018
@zachleat zachleat added this to the v0.2.15 milestone Mar 3, 2018
@zachleat
Copy link
Member

zachleat commented Mar 3, 2018

Alright, I added 16 new tests for this, 9 of which are currently skipped in the test suite but will apply after harttle/liquidjs#61 is fixed.

For now (after Eleventy 0.2.15 is released), you can use the Configuration API to enable dynamicPartials in the liquid options, and this will work as expected—but will require all of your include paths to be quoted. So, instead of {% include form/contact %} you’d need to do {% include "form/contact" %}.

Your .eleventy.js config file might look something like this:

module.exports = function(eleventyConfig) {
  eleventyConfig.setLiquidOptions({
    dynamicPartials: true
  });

  // your other config stuff
};

I’m tempted to make this the default, but want to make Jekyll migrations as easy as possible—so I’ll probably end up banking on this being easier if it’s fixed upstream in liquidjs for now. Hope this is an ok solution for you!

@zachleat
Copy link
Member

zachleat commented Mar 3, 2018

Closing this, filed a longer term issue for the upstream fix here if you’d like to subscribe: #73

@zachleat zachleat closed this as completed Mar 3, 2018
@paulrobertlloyd
Copy link
Contributor Author

Wow, thanks @zachleat! Still investigating 11ty, but if I were to migrate I’d likely move to using Nunjucks soon after. But in terms of being able to support Jekyll sites, I think this is a really helpful addition. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants