Flag for "don't evaluate this templater block"!

Premise

It would be excellent to have a Templater syntax that tells Templater to pass whatever is inside the block verbatim, instead of trying to evaluate it when the note instance is created.

Use case

For work and managing my D&D campaigns, I use a system of templates containing buttons for generating backlinked notes of various types automatically (i.e. deploying other templates).

For example, my D&D Session template include buttons to spawn: new NPCs or Artefacts or Lore… Each of which comes from another template. The backlinking to the “source note” works via a simple script (prompting for a downstream note title, and so on).

Problem

Originally, my D&D Session template created buttons in this way:

button
name New NPC
type note(NewNPC <% tp.file.title %>, split) template
action NPC_Template
templater true

So if I’m creating a new Session note, titled MyOriginalFileName, then I end up with an instance of the button with the source note’s title hard-coded at the time of creation. Something like this:

button
name New NPC
type note(NewNPC MyOriginalFileName, split) template
action NPC_Template
templater true

Which means my downstream notes will all reference “MyOriginalFileName” instead of referencing the current title of the source note.

Hacky Solution

I’ve gotten around this by adding a const to my D&D Session template, which smuggles in the code I don’t want evaluated when the D&D Session note instance is created:

<%* const sneakyText = "\<% tp.file.title %\>" %>

Where my buttons are now created with the following Templater instructions:

button
name New NPC
type note(NewNPC <% sneakyText %>, split) template
action NPC_Template
templater true

Which results in the code I wanted in my Session instance:

button
name New NPC
type note(NewNPC <% tp.file.title %>, split) template
action NPC_Template
templater true

Downstream notes created with this button are now seeing the source note’s current title, instead of its original title.

Final thoughts

I leave the possibilities unlocked by native support for this kind of “ignore Templater code” and second-order template interactions as an exercise for the reader :stuck_out_tongue: