Nubie question—template tags

#1

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+")");

0 Likes

#2

You want getTemplateTag();

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

Example action


0 Likes

#3

Fabulous. Thank you!

0 Likes

#4

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.

0 Likes

#5

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

0 Likes

#6

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

#7

Great. Thanks :sunglasses:

0 Likes