SOLVED

3 very crucial questions regarding Apache Velocity email script tokens in an email

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

It's not so much the closing tag being outside (it could well be in another Velocity token). It's that the only supported output, if you need a tracked + functional link, is to output the entire tag, from <a> to </a>, from the same {{my.token}}.

Why is it that you can't output the whole thing from VTL? Not getting that part.

Anonymous
Not applicable

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

I can output the whole thing from VTL, but only for one particular link value. For instance, if the script token outputs a value of: <a href="link">My Link</a> it CANNOT ALSO output a value of say <a href="link">Another Link</a> or <a href="link"><img src="image"></a>. It can only do one!

What I'm trying to accomplish is have the email script output a link, like "https://$mylink" scattered around an email: sometimes being linked to a single word, another time to a full sentence, and then maybe again to an <img>. But again, the problem I face is that if I have to include both the opening and closing anchor tags in the script itself, then the value that lies between the tags is static.

SanfordWhiteman
Level 10 - Community Moderator

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

Yes, you'd have to find a way to make the inner text and/or elements generated in Velocity as well.  Combining VTL-contributed HTML pieces (in token/s) with end-user-contributed pieces (in the email body itself, including in variables) is difficult-to-impossible.

A notable exception is using comment tokens (containing just the text "<!--" and "-->"), but that's for suppressing user content as opposed to merging VTL+user content in a functional way.

Standalone text or elements from each source can be combined, of course, but trying to construct <element>s from pieces of both is almost guaranteed to fail.

Anonymous
Not applicable

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

That is extremelt insightful, thank you. It's a bummer though. 😕

So, just to confirm, in your experience the **only** way to construct a link via an email script token is by including both the opening and closing anchor tags within it?

SanfordWhiteman
Level 10 - Community Moderator

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

So, just to confirm, in your experience the **only** way to construct a link via an email script token is by including both the opening and closing anchor tags within it?

That's my experience, though it's tricky enough to get the links tracked correctly (esp. with multiple links) that I can't say I've really pushed it much with just a partial <a> tag. Maybe you'll find a lucky bug!

Anonymous
Not applicable

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

You've been extremely helpful, Sanford. Thank you for this thread and the 100s of other threads you've helped others and me!

SanfordWhiteman
Level 10 - Community Moderator

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

Sure!

Anonymous
Not applicable

Re: 3 very crucial questions regarding Apache Velocity email script tokens in an email

And sorry when I refer to text, I'm referring to HTML rich text, not plain text! Forgot to make that distinction!