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.