Templater: How to insert and expand another template in current file passing a variable

What I’m trying to do

Let’s say I have a template file (e.g., “t1.md”) with the following:

# <% `${referenceDate.format("YYYY-MM-DD")}: ${referenceDate.format("dddd")}, Week ${referenceDate.format("WW")}` %>

I want to call this from the following template:

<%-*
const referenceDate = moment()
_%>

// I want to insert and expand "t1.md" here, with today's date

and the following template:

<%-*
const referenceDateStr = await tp.user.promptAndParseNaturalLanguageDate(tp, "Reference Date", "", true, false) 
const referenceDate = moment(referenceDateStr, "YYYY-MM-DD")
_%>

// I want to insert and expand "t1.md" here, with the user specified date

Things I have tried

<%-*
const referenceDateStr = await tp.user.promptAndParseNaturalLanguageDate(tp, "Reference Date", "", true, false)
const referenceDate = moment(referenceDateStr, "YYYY-MM-DD")
tp.file.include("[[t1]]")
_%>
<%-*
const referenceDateStr = await tp.user.promptAndParseNaturalLanguageDate(tp, "Reference Date", "", true, false)
const referenceDate = moment(referenceDateStr, "YYYY-MM-DD")
_%>

![[t1]]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.