Does advanced pdf / freemarker support using somet...
# advancedpdf
a
Does advanced pdf / freemarker support using something like || operator of js? What I am trying to accomplish is something like this
Copy code
<td class="address" colspan="6" rowspan="2">${record.billaddress} || ${record.shipaddress}</td>
I don't want to start with ifs and else since in my case I already have a bunch and it would get very messy to start adding ifs to all of them
s
You can try to combine them into a single statement like this:
${(record.billaddress?length == 0)?string(record.shipaddress, record.billaddress)}
a
Thanks. Was just trying something like that with
.then
but was having trouble because it expects a boolean value and I am so used to JS that I assumed it would just evaluate
I'll give it a shot
m
If you are doing this a lot a coalesce macro would make things much cleaner
Something like
Copy code
<#macro coalesce args...>
   <#list args as arg>
     <#if (arg!"")?length gt 0>
       ${arg}
       <#break>
     </#if>
   </#list>
</#macro>
which you could then use
Copy code
<@coalesce record.billaddress record.shipaddress />
Also I'm not sure if the version of freemaker NetSuite uses supports
?then
, but if it does you should be able to do
Copy code
${(record.billaddress?length gt 0)?then(record.billaddress, record.shipaddress)}
message has been deleted
a
Oh cool! I didn't know about that site! Looks like a good tool @michoel We gotta get you in the same timezone buddy!