Nubie question—template tags

I have a prompt in a previous step. And then I just want to use the text they enter in my script. The script won’t even run. I’ve spent too much time searching around and can’t figure out the problem. What obvious thing am I missing?

var ref = draft.getTag(‘prompt_text’);
editor.setSelectedText("("+ref+")");

You want getTemplateTag();

var ref = draft.getTemplateTag("prompt_text");

Example action


Fabulous. Thank you!

getTemplateTag does work, but I would suggest the canonical way to do this would be to use draft.processTemplate(templateString). Per your example:

let ref = draft.processTemplate("([[prompt_text]])");
editor.setSelectedText(ref);

Mostly because it allows you to handle the additional text content without having to concatenate strings.

1 Like

I can absolutely see the benefit of that approach, but that leaves me wondering, when would you recommend using getTemplateTag over processTemplate?

I wouldn’t necessarily recommend it…nothing really wrong with it, either. Mostly preference.

I think the most obvious use case might be branching logic, if you want to test for the button selected in a previous prompt step.

1 Like

Great. Thanks :sunglasses: