I’d like to figure out a way to retrieve values from a text (XML or other) file within the bindings or code of a Velocity template. This would be a way to remove some of the literals from our template bindings and code, and store them in files that we can change whenever we want, without making and deploying a code change.
For example, we have a parameter value that we want to add to various URLs on one of our pages, and right now we put that value in a binding in the page template:
$quote_eventid = 69263
(it’s actually in the binding tab, but I’m just using abbreviated syntax here).
If that event ID changes, we need to change our template. It would be nice to just change a value in the Velocity equivalent of a properties or config file.
Thanks for that suggestion. That could be an improvement - we would only need to change a value in a database, rather than a template.
Retrieving from a file on the file system would be even better, because we could have our users maintain it directly (rather than needing a developer to change a value in the database).
Similar to keeping track of variables in one place, you could create a velocity macro that returns the variable value based on what is passed to it. Of course at this point you would just maintain the variables and values in the velocity macro file (so you would still have to promote that to get a change through…but strictly speaking, it is a file )