Templating: allow import name to be dynamic
Open
@mikeerickson is already working on this.
Since Jan 11, 2024.
- Dominant language
- JavaScript
- Stars
- 204
- Forks
- 82
- Avg merge
- 22h 27m
- Merged PRs (30d)
- 3
Description
A user has created a template that dynamically imports a template based on the day of the week.
What would be ideal would be to allow this import to load a template based on the calculated day, e.g.:
const daysOfWeek = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
const today = daysOfWeek[this_date.getDay()]
const templateName = `☀️ Daily Note - ${today}`
...
<% import(`${templateName}`) -%>
This doesn't work as the code is currently written.
The string in the import statement is treated as a literal and is not interpolated.
***************************************************************************
ERROR
Method: NPTemplating.getTemplate:
Message: Template "${templateName}" Not Found or Empty
***************************************************************************
Would be nice to allow this to be dynamic so that the code above would load "☀️ Daily Note - Mon" or "☀️ Daily Note - Fri"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.