I have a script that drives a ‘Lightbox’ type image gallery as prt of my Detail page in a custom module. Is it possible to use custom module Liquid tags inside the javascript? eg.
If your JS in on the page (not an external source) then yes, you can use Liquid to populate the JS. It’s just content at that point of rendering (front-end).
If you’re sample isn’t working it’s likely the Liquid output is not what you are expecting and something is breaking the JS, or in this case making the JSON invalid (like non-escaped HTML elements).
Actually, it looks like your JSON is not quite valid in your sample.
The “width” property has no value (needs an empty string perhaps “”) and that very last comma shouldn’t be included (unless there are more items…).
Thanks Adam - you’re right (as usual)… the generic ‘width’ was missing so broke the JS. Wasn’t 100% sure you could use Liquid in the JS but working OK now. Thanks again for your help (and patience) - that’s about a box of fine red I owe you - Cheers!