Forum Discussion
AndrewF
6 years agoKhoros Oracle
I believe this has something to do with the way we implement <@delegate> internally combined with the way FreeMarker's block <#assign> works. Are you able to get around it by forcing a read, like <#assign dummyvariable = markup[0..]> ?
I had some other ideas for improvements:
- I'd recommend moving your <#if markup?contains("Recommendations")> as high as possible so that you don't do more work than necessary.
- Instead of using ?seq_contains, use our utils.sequence.unique(ids) utility method at the end.
- If you only intend to build ids so that you can iterate over it later, consider interleaving your "LOGIC" and "DISPLAY" loops so that you can space out some of your API calls.
- You don't need to escape a backslash in a regular expression string. ?matches("-p/(\\d+)") is fine.
Note that the DOM is not related here -- at the point this template is being processed, there is no HTML DOM. FreeMarker is maintaining its own data structure that represents the parsed template, and it is building pure text. Later on the other end of the wire, a browser will parse the text into a DOM.