I may be missing something, but it looks like you can only interact with either the title or the entire contents of a draft through scripting (without resorting to parsing the draft contents in the script.)
It would be handy to interact with just the body through draft.body or a specific line like draft.line[6] or something like that.
Could you elaborate by what you mean by āinteract withā and how it could be easier? Or what you are trying to accomplish?
You can extract lines and such pretty flexibly with the template engine (tags like [[line|2..4]]
). Without details itās hard to say.
Or do you mean āall the paragraphsā as an array? or āall the headingsā? Or āall the sectionsā? Here a section starts with a heading and carries on to the next heading. (Actually in md2pptx I - since yesterday - deem a horizontal rule as another section boundary.)
I think you can do all this in javascript, BTW. Iām just exploring your meaning and use cases.
Sure, Iāll try to elaborate a bit better.
So Iāve been working on a script (Help - adding to Jira) to add items to Jira. Iād like to pass the title of the draft in as the issue summary, and the body in as the issue description. So ideally Iād like to do something like this:
var summary = draft.title
var description = draft.body
The behaviour of the above is āsummaryā will have a value populated from the title, but ādescriptionā will be undefined.
To get around it, Iām currently adding a step in the action before the script gets run to copy the [[body]] to the clipboard, then declaring description with
var description = app.getClipboard();
So, in a way, I am using the template engine for this purpose, but it just feels kludgy to me to pass the data to the script through the clipboard. I guess what Iām getting it, is, is there a way to directly use template tags within a script itself?
1 Like
The āproperā way to do that is use the template engine, like:
var description = draft.processTemplate("[[body]]");
This works with any of the supported template tags in the template, just like you were configuring a template in other action steps.
1 Like
Ah, thanks, somehow I missed that function when I was looking at the scripting documentation. That totally solves this - thanks!
Iām curious, whatās the rationale of having the .title function in scripting as its own special thing? Or was that just a holdover from before the template engine was introduced?
1 Like