As a relative newbie to Java and Velocity templates, some absolute pain I’ve endured is Velocity insisting on interpreting $ as a variable even when it’s included in JavaScript.
The app I’m working on uses a lot of Alpine, and so the magics like $dispatch, $el and similar get interpreted into Velocity-side variables!
Turns out there’s a simple solution: wrapping your code in a special ‘include but do not parse’ syntax: