Closed bhainesva closed 6 years ago
I see. Because this was done at execution time instead of compile time it was adding print directive each time the template was executed. Can the adding of a print directive be done at compile time instead, activated via an option? I'm a little dubious that this mechanism needs to be more general than a "print empty string instead of null" option, so maybe it can be more specific too. There are few print directives that would make sense to apply to EVERY node. I think this is pre-mature generalization
@robfig I'm wondering how we would make that work with SoyJS. Directives seemed like a good path to take since they are already plugged in to all the right places of soyhtml and soyjs.
@robfig bump!
Whoops, sorry for missing the reply.
I'm suggesting that we would use print directives, but we would apply them while compiling instead of at runtime by checking a global variable.
Looking at the code, bundle.go:147 applies a few rounds of post-compilation modifications ("parsepasses"). This could easily fit into that model, so e.g.
func (*Bundle) AddParsePass(func(template.Registry))
How about that?
…nce impact
Results from running the tests from @meirf.
Before my initial change:
After my first change which caused problems:
This updated version: