-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Replace default swig engine with nunjucks #2903
Conversation
Replace swig with nunjucks v3. |
Thanks @kovtunos. Shall we still process |
At the moment all swig tests seem to pass with nunjucks as a renderer. Except one which is related to the The test is ran against this data structure: var data = {
arr: {
toArray() {
return [1, 2, 3];
}
}
}; Is that something we want to keep? Is that related to a Collection object (like posts) which has a I would find it less hacky to write |
Hi @oncletom , my two cents, we should keep the backward capability. The most popular Hexo theme NexT (https://github.com/iissnan/hexo-theme-next) is still using the swig. However, if the change could work on NexT, then we could merge this change for Hexo 4. |
1 similar comment
hi, this is an exciting proposal. it will make it possible to use async helper in themes. |
The next theme is now hosted here -- https://github.com/theme-next/hexo-theme-next/ |
@oncletom, is this still working in progress? |
Hi @NoahDragon! I would say most of the work is done. At the moment nunjucks is configured to handle Next step would be to try it out with I don't know if anybody has time to do it, or to test and to report the issues in this thread. Otherwise let me know if there are any useful pointers to integrate this contribution to the |
@oncletom Thanks for the update. I will test this change when I have a chance. 😄 |
What's the status on using Nunjucks? I'm only pointing this out because the official site no longer mentions it along side of pug, ejs, haml and swig. https://hexo.io/docs/themes.html#layout Besides, it seems *.ejs is currently the adopted template language of Hexo. |
it looks like nunjunks is merged to node itself. And it cause some errors to install hexo on node 11.3.0. #3380 |
@chenbojian it's unrelated to this issue |
Well, I don't know—I can put more efforts into it. I can also make it a separate plugin if needed and if none already exist to do the job. Any feedback from the @hexojs team? |
IMHO, should merge this change and bump up to hexo version to V4. No need separate to plugin. |
Any progress? @oncletom maybe you need to resolve the conflicts. |
I found that it's impossible to render swig template with nunjucks engine, since they have minor different syntax, see https://medium.com/engineers-optimizely/js-templating-transitioning-from-swig-to-nunjucks-ac0e94d1794b
So either totally remove swig, or don't add nunjucks renderer. You shouldn't render swig with nunjucks. |
Interesting, thanks for sharing this conclusion. Shall we not render both of them and make it a separate renderer instead? |
Sorry, I made a typo: I was not referring to Switching to Nunjucks was already a breaking change. I have no idea if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Pending hexo-renderer-nunjucks
joins hexo official plugins and releases a new version.
@NoahDragon Please add @oncletom to plugin team at GitHub org.
@SukkaW I invited you as a collaborator on the repo so as you can do the transfer — maybe, if that works? A new version of |
Emmm, nope. I have accepted the invitation, but BTW, for NPM you could add |
@oncletom I have asked Hexo orgs owner to send your invitation to join |
Okay, thank you @SukkaW. Also, now I think about it, if you have the correct permissions, you can create an empty repo in the Regarding the npm repo itself (https://www.npmjs.com/package/hexo-renderer-nunjucks), I don't have write access to it. These persons can add
|
@oncletom Thanks :) |
Currently hexo's built-in swig renderer is using some ES6 syntax that
@NoahDragon Would you mind adding @curbengh ( |
Thank you 🙂 I have transferred the repo. It now lives as hexojs/hexo-renderer-nunjucks 🙌 I added a note in the README to automatically publish a release on npm, for every new Git tag pushed to GitHub. Once the env variables are set, creating a Then this comment can be addressed, by committing the suggestion. I have updated this PR description to reflect these steps. |
@JLHwung @NoahDragon As you are the owners of |
@ertrzyiks Hi, it seems that you are an owner of hexo-renderer-nunjucks. Would you mind adding @oncletom ( |
2cdecbf
56dea0b
to
2cdecbf
Compare
Thank you @ertrzyiks, as well as @SukkaW for chasing this down 🙂 hexo-renderer-nunjucks@2 is live on npm, and this PR has been updated accordingly 👍 |
It feels reasonable to remove swig due to its deprecation and various issues reporting it: #2895, #1593, #1625, #1915, #2295
This PR aims to:
choice 1, replacing swig with nunjucks as a native renderer (and then processing.njk
files)hexo-renderer-swig
to opt-in for legacy themes,hexo-renderer-j2
orhexo-render-nunjucks
orhexo-renderer-nunjucks2
etc. to opt-in for nunjucks)ensure default theme iissnan/hexo-theme-next is compatible with the outcome of this PRtheme-next now embeds its own flavour of nunjuckshexo-renderer-nunjucks@v2.0.0
release will publish the updated package.hexo-renderer-nunjucks@v2.0.0
, as published on npm.What do you think?