NotePlan / NotePlan/plugins

Templating: allow import name to be dynamic

Offen
#514 0 Kommentare 1 Reaktion 1 zugewiesene Person Auf GitHub ansehen

@mikeerickson arbeitet bereits daran.

Seit 11.1.2024.

Vorherrschende Sprache
JavaScript
Sterne
204
Forks
82
Ø Merge
22 Std. 27 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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"

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.