Skip to main content
Jo_Pitts1
Community Advisor
Community Advisor
Feb 19, 2020 12:55 AM UTC
Question

Velocity directly in template modules

Good afternoon all.

is it possible to write velocity code directly against a module in an email template, or do I need to abstract it by referencing a script token in the template?  

I'd like to build out a module that has the ability to comment itself out (often referenced here) without needing to add tokens in the email itself, and am curious as to best practice.

Cheers

Jo

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

SanfordWhiteman
User Group Leader
User Group Leader
Feb 19, 2020 1:02 AM UTC

It is possible to write a limited amount of VTL directly in a template (this is the reason that there are reserved words in templates). However, this is in no way supported, and I advise as strongly as possible that you not rely on it.

 

If you want to conditionally comment out a section, you should wrap it in Velocity {{my.token}}s.

Translate
Jo_Pitts1
Community Advisor
Jo_Pitts1Community AdvisorAuthor
Community Advisor
Feb 19, 2020 2:55 AM UTC

Makes sense (and yes, I was already predicting problems with reserved characters).

 

Next silly question - can module variables be referenced in Velocity.  E.g., I set the a variable called 'colour' to 'BLUE' on the module, and then depending on whether a lead has a checkbox 'loves_blue' checked leave the module on display, otherwise comment it out?

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Feb 19, 2020 3:10 AM UTC
Unfortunately not, those vars can't be used in VTL.
Translate