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

feat: support 'disableNunjucks' in front-matter #4518

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Sep 4, 2020

What does it do?

Requested by #3259 cc @noraj

Although the behavior of `{{ }}` (with backtick wrap) is now working as expected since v5, user may want to use {{ }} without backtick wrap for certain articles (post/page). With this PR, when disableNunjucks are disabled globally (default) or through a renderer, user can enable it per article; at the same time, it is also possible to disable it per article even when it is enabled globally.

enabling disableNunjucks will disable processing of {{ }} / {% %} and tag plugins.

How to test

git clone -b fm-disable-nunjucks https://github.com/curbengh/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

coveralls commented Sep 4, 2020

Coverage Status

Coverage increased (+0.0005%) to 98.3% when pulling c6b2691 on curbengh:fm-disable-nunjucks into e30605d on hexojs:master.

.mocharc.yml Outdated Show resolved Hide resolved
lib/hexo/post.js Outdated
@@ -259,6 +259,9 @@ class Post {
}
}

// front-matter overrides renderer's option
disableNunjucks = typeof data.disableNunjucks === 'boolean' ? data.disableNunjucks : disableNunjucks;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be done before checking the renderer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

front-matter should override renderer in this case.

@curbengh curbengh force-pushed the fm-disable-nunjucks branch from b54311c to c6b2691 Compare September 5, 2020 01:38
@curbengh curbengh requested review from SukkaW and removed request for SukkaW September 5, 2020 01:56
@curbengh curbengh requested a review from a team September 13, 2020 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants