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

Frontmatter Variable Substitution doesn't work in V2 Preview/Publishing #1322

Closed
2 of 6 tasks
aleksey-rowan opened this issue Sep 11, 2021 · 7 comments
Closed
2 of 6 tasks
Assignees
Labels
area.misc kind.crop scope.publish Static site generation, sending note links and anything to do with publishing your notes. type.bug Something isn't working

Comments

@aleksey-rowan
Copy link
Contributor

Please select the area your Bug applys to. (Multiple selections are Possible)

  • Onboard. Initial vault setup and import/export pods
  • Create. Note creation, lookup, snippets and templates
  • Retrieve. Backlinks, references, graph view
  • Structure. Refactoring, multi-vault and schemas
  • Publish. Sharing your repo with the world
  • Misc (Choose this if your not sure)

Describe the bug

Frontmatter variable substitution doesn't work in V2 preview; it seems it hasn't been carried over from V1.

To Reproduce

Steps to reproduce the behavior:

  1. Add a new variable to the frontmatter (mood: ambivalent)
  2. Use the variable in the note ({{fm.mood}})
  3. Open V2 preview
  4. Observe that the variable value is not interpolated into the text and the note simply shows {{fm.mood}}

Expected behavior

Frontmatter variable substitution should work in V2 the same it does in V1.

Screenshots

Desktop (please complete the following information)

  • Version 0.58.1
@github-actions github-actions bot added area.misc scope.publish Static site generation, sending note links and anything to do with publishing your notes. status.triage-needed type.bug Something isn't working labels Sep 11, 2021
@kevinslin kevinslin added this to Potential in Community Issue Board via automation Oct 19, 2021
@kevinslin kevinslin moved this from Potential to In Progress in Community Issue Board Oct 19, 2021
@aleksey-rowan
Copy link
Contributor Author

After the fix, it seems that useNunjucks: true is required for variable substitution to function. Otherwise, everything seems to work as expected.

@hikchoi hikchoi added status.info-needed More information is needed from filer for issue to be actionable and removed status.triage-needed labels Oct 27, 2021
@hikchoi
Copy link
Contributor

hikchoi commented Oct 27, 2021

Thanks for the feedback on the fix @aleksey-rowan

Note on Nunjucks:
Currently Nunjucks is only used for frontmatter variable substitution and the overhead is quite large. We are planning to change it so that enabling Nunjucks isn't required for variable substitution works in the following week.

Please do let us know if you have any other concerns with this issue. Otherwise, this issue will be automatically closed in 4 days.

@aleksey-rowan
Copy link
Contributor Author

@hikchoi I tried some more and out of the standard frontmatter values, only {{ fm.title }} works; others (created, updated, desc, and id) are not rendered.

Custom frontmatter values do get rendered and that's why I didn't catch the above right away.

@no-response no-response bot removed the status.info-needed More information is needed from filer for issue to be actionable label Oct 28, 2021
@hikchoi
Copy link
Contributor

hikchoi commented Oct 28, 2021

@aleksey-rowan

others (created, updated, desc, and id) are not rendered.

This is expected behavior.
The currently exposed variables are:

  1. {{fname}} (exposed by nunjucks itself)
  2. {{fm.title}}
  3. any custom frontmatter

It was implemented this way since it was first introduced, but I am blanking on the rationale behind it.
@kevinslin Could you give us some insight on why the other frontmatter variables aren't exposed?

@hikchoi
Copy link
Contributor

hikchoi commented Nov 10, 2021

As of v68 we have removed the Nunjucks dependency and frontmatter variable substitution will work out of the box.

We've also added created, updated, and id to the exposed frontmatter object.

@hikchoi hikchoi added the status.info-needed More information is needed from filer for issue to be actionable label Nov 10, 2021
@aleksey-rowan
Copy link
Contributor Author

Seems to work without Nunjucks. Thank you! 👍 Does it mean that the useNunjucks option is deprecated?

Also, any reason for leaving {{ fm.desc }} out?

@no-response no-response bot removed the status.info-needed More information is needed from filer for issue to be actionable label Nov 11, 2021
@hikchoi
Copy link
Contributor

hikchoi commented Nov 15, 2021

useNunjucks is not yet removed from the configuration but has no effect now.
No particular reason desc was left out. I just missed it 😅 I'll add that in real quick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area.misc kind.crop scope.publish Static site generation, sending note links and anything to do with publishing your notes. type.bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

3 participants