Skip to content

Passthrough templater syntax #1140

Answered by twiddli
twiddli asked this question in Help
Discussion options

You must be logged in to vote

Thought up a solution right after hitting submit. Classic.

I ended up creating a user script named utils.js with the following function:

class Utils {
  function t(content, type = "+") {
      return `<%${type} ${content} %>`;
    }
}
const utils = new Utils();
exports.default = () => utils;

It's important that this resides in a user script or it won't work.

Now I can use it like this inside a template note

<% tp.user.utils().t("'test'") %>

Which results in a note with

<%+ 'test' %>

The type of command can be specified with a second argument: <% tp.user.utils().t("'test'", "*") %> for <%* 'test' %>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by twiddli
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants