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

Cannot use nunjucks in a sub-site #931

Closed
damithc opened this issue Jul 14, 2019 · 8 comments · Fixed by #1263
Closed

Cannot use nunjucks in a sub-site #931

damithc opened this issue Jul 14, 2019 · 8 comments · Fixed by #1263
Labels
a-Syntax p.High To be done in the next few releases

Comments

@damithc
Copy link
Contributor

damithc commented Jul 14, 2019

Problem: if a page in a subsite uses nunjucks, the scripts will not work if that page is used in the outer site.

@ang-zeyu
Copy link
Contributor

ang-zeyu commented Apr 4, 2020

Hmm what script produced this?

I've tested with macros, if-else's, for loops and they seem to work fine

@damithc
Copy link
Contributor Author

damithc commented Apr 4, 2020

This was just a guess, because nunjucks import statements need to specify the path from the root of the site. Perhaps it's already taken care of.
Are you able to get the script to work in the sub-site (i.e., when you generate the site for the sub-site without the outer site) and also when the sub-site included in the outer site.

@ang-zeyu
Copy link
Contributor

ang-zeyu commented Apr 4, 2020

This was just a guess, because nunjucks import statements need to specify the path from the root of the site. Perhaps it's already taken care of.

Will test imports out as well

Are you able to get the script to work in the sub-site (i.e., when you generate the site for the sub-site without the outer site) and also when the sub-site included in the outer site.

Yup, I used a markbind <include> though, will experiment with nunjucks includes.

@ang-zeyu
Copy link
Contributor

ang-zeyu commented Apr 4, 2020

Tested the following: ✅

  • markbind <include> a sub site's md/html file that uses a mix of for loops, macros on its own
  • {% import %} ing a sub_site's md/html from the main site, and then using it
  • {% include %} ing a sub_site's md / html file from the main site that uses a mix of for loops, ...
    • baseUrl resolves to the main site unlike markbind includes as expected
    • output is as expected
  • {% import %} from a sub site's file, then <include> / {% include %} it in the main site

What fails is the following as mentioned:

script to work in the sub-site (i.e., when you generate the site for the sub-site without the outer site) and also when the sub-site included in the outer site.

ie. {% include/import xx %} in a sub site, where xx is from the root of the sub site.
It works when building the sub_site alone, but fails when including it in the main site as xx is resolved from the main site.

Will see if it can't be fixed

@damithc
Copy link
Contributor Author

damithc commented Apr 4, 2020

possibly related #684

@damithc
Copy link
Contributor Author

damithc commented May 30, 2020

This is actually a serious flaw that went undetected because our only sub-site (se-edu/se-book) hasn't uses nunjucks up to now. It's good if we an fix it soon.

@damithc damithc added p.High To be done in the next few releases and removed p.Medium labels May 30, 2020
@ang-zeyu
Copy link
Contributor

possibly related #684

The solution used in it is related, but instead of configuring one nunjucks instance per page, it should be one per (sub)site.

In my initial attempt I found the solution added quite some repeated boilerplate on the existing variable processing logic (we have quite a bit of non-centralized, duplicated variable processing code), hence I think its better to wait for #1189 to be merged as a minimum.

I think the best point to fix this is still 1-2 more refactor PRs away after #1189 though, would that be fine? @damithc

@damithc
Copy link
Contributor Author

damithc commented May 30, 2020

I think the best point to fix this is still 1-2 more refactor PRs away after #1189 though, would that be fine? @damithc

Sure, can wait as long as we are working towards a solution. Thanks @ang-zeyu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-Syntax p.High To be done in the next few releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants