You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it's required to use some well-known methods inside of the template (like string.ToUpper()) and in order to do so you need to register new helper for each of such occurrences.
Solution
Right now there are two stages for helper binding:
compile time: helper is registered before template is compiled
late bind: helper is registered after template is compiled
I propose to add a third step, controlled by feature toggle in settings, that would try to resolve and invoke:
instance method of the object
static method of the type (if instance method was not found)
Adding the feature toggle is essential for a few reasons:
potential unexpected behavior due to lack of support in Handlebarsjs (see section below)
potential performance degradation (may be resolved by adding Compile<ExpectedModelType>() mentioned in 2.0 Planning #294 )
Support in Handlebarsjs
There was a discussion (handlebars-lang/handlebars.js/issues/168) regarding this functionality. The proposal was rejected. However for JS there's workaround mentioned in the same thread - you can override the handler. Unfortunately such overrides are not available in current implementation mostly because of .NET nature.
Useful for
The functionality may be useful for people who does not have strong performance requirements but require more feature reach and flexible templating engine. One of the examples may be generation of deployment artifacts (e.g. ARM template parameters generation).
Problem
Sometimes it's required to use some well-known methods inside of the template (like
string.ToUpper()) and in order to do so you need to register new helper for each of such occurrences.Solution
Right now there are two stages for helper binding:
I propose to add a third step, controlled by feature toggle in settings, that would try to resolve and invoke:
Adding the feature toggle is essential for a few reasons:
Compile<ExpectedModelType>()mentioned in 2.0 Planning #294 )Support in Handlebarsjs
There was a discussion (handlebars-lang/handlebars.js/issues/168) regarding this functionality. The proposal was rejected. However for JS there's workaround mentioned in the same thread - you can override the handler. Unfortunately such overrides are not available in current implementation mostly because of .NET nature.
Useful for
The functionality may be useful for people who does not have strong performance requirements but require more feature reach and flexible templating engine. One of the examples may be generation of deployment artifacts (e.g.
ARMtemplate parameters generation).