How can i programmatically modify a template before rendering

In order to support new paths for my images, I need to programmatically examine and modify some of my

<img src="old-path">

tags in my templates, before they are rendered by blaze.

It it possible to hook in somewhere when the template is first loaded to make such changes to a template?

Can’t you use spacebars

<img src=“{{checkAndUpdateLink “old-path”}}”>

1 Like

Yes, that works.

But in fact i have hundreds of individual pages that get imported into my main template, each with their own image tags, and several apps that use this process, so modifying them all to use helpers would be a huge job. Besides helpers don’t work on pages imported using {{{sub-page.html}}}

I’d like a single place to modify the paths on the fly.

You can create global helpers using “Handlebars.registerHelper”

I also tried that but even global helpers are not run on html read in through {{{sub-page.html}}}

I will probably end up having to branch Blaze and embed something to do my conversion