How to properly hook into the Phoenix template and HTML.Engine system to run an html minifier

Hi all,

I have found an HTML minifier written in rust that I wrote a NIF wrapper for with rustler.

I would like to run it against all my HTML templates, ideally at compile time (but if it has to happen at render time I’d like to experiment with that too).

Where would be the best place to ‘hook’ into the Phoenix systems of the Engine and formatters? I’ve tried hooking into the function called encode_to_iodata in Engine, but the problem is it seems to really want you to return an IOData, and if I call out to this lib I feel like I’m going to get a binary back no matter what.

1 Like