Hi. I created the template shown in the image below, but, when I create a new draft from this template, I’d like it to remove the title so I can input my own. However, I still want the title in the template as an identifier when I’m choosing a template. Is there any special code/symbols that I should surround the title in so it doesn’t appear in the actual draft?
How are you generating your new draft from your template?
i.e. Utilising this action?
If so, you should be able to get just the body rather than the full content of the note being used for the template by modifying the action and changing:
d.content = d.processTemplate(template.content);
let astrLines = draft.lines; astrLines.shift(); d.content = d.processTemplate(astrLines.join("\n"));
There are other ways to do this, but I think this might be a reliable and easy to understand one … RegEx might lead to too much complexity to cater for escaping title content and erroneous single line templates.
That is the action I’m using. I tried replacing the code with what you suggested, but all it did was give me a blank draft.
I was hoping there were some symbols I could surround my title with that Drafts would recognize & ignore.
@sylumer was close…minor change to his suggestion:
let astrLines = draft.lines; astrLines.shift(); // use "draft", not "d" in line below... d.content = draft.processTemplate(astrLines.join("\n"));
Hmm. It’s still giving me a blank draft.
I can see what my earlier mistake was, I missed amending
template in the first of those replacement lines. It should have been this:
let astrLines = template.lines; astrLines.shift(); d.content = d.processTemplate(astrLines.join("\n"));
I’ve applied it to a copy of the original action and tested it with a template and it works for me. However, I have also set it to use
draft rather than
d in the line for the
processTemplate step as per Greg’s note (see below).
I get that the current draft would probably be best (for processing any custom template tags for example), but that was part of the original code, so it probably needs amending in the original action too.
Ha! I saw the problem in reverse. Vacation brain.
That fixed it, thank you!