Inserting "invisible" comments in templater scripts

For few days I was looking in the forums and templater documentation for a way to document templater scripts with comments that do not transfer to the newly created note. I couldn’t find the way and ended up surrounding my comments with % sign, which is ugly because the comment will show up in the note.

Finally found the answer in this post that the author uses to rename tags in multiple notes by using a note selector.

This is how adding “invisible” comments works. In the templater script add something like this:

This comment WILL NOT APPEAR in the note where the template is executed.
You can insert comments, using this format, anywhere in the templater script. The comments will not pass to the note over which the template is being applied.

The resulting notes will be clean but your templates will be thoroughly documented for your future self after few months.


Thanks so much for such grace, is indeed working on my Templater plugin 2.2.3

Would you be so kind to provide source or how your discovered this?

Not OP, but it looks like a straight-forward application of the rules: It’s a code template snippet, that contains a code comment.