NotePlan / NotePlan/plugins

Templating: allow import name to be dynamic

Aperta
#514 0 commenti 1 reazione 1 assegnatario Vedi su GitHub

@mikeerickson ci sta già lavorando.

Dal 11/1/2024.

Lingua principale
JavaScript
Stelle
204
Fork
82
Merge medio
22h 27m
PR unite (30g)
3

Descrizione

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"

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.