handlebars-rust icon indicating copy to clipboard operation
handlebars-rust copied to clipboard

extracting unused parameters?

Open mojindri opened this issue 1 year ago • 1 comments

Hi, Let's say we have built a couple of partials with these names "Car" and "Airplane", which are also connected to JSON objects of the same names. Each of these objects has a field named "Name", and in the partials, this field is used to print the "Name" value. However, the developer made a mistake and in the "Car" partial, he forgot to write

{{Name}}

. Normally, this is not an error from the Handlebars engine's perspective, but as a programmer, I would like to provide functionality so that if the "{{Name}}" field is not defined, the system will fail. do you have maybe suggestions? is there any workaround maybe? lets say, is it possible get a list of parameters from handlebars engine where "{{}}" statements are used in "Car" partial? regards,

mojindri avatar Feb 09 '23 17:02 mojindri

We might be able to do it with a helper, that logs or just counts its references. For example, write {{tracked Name}} in your template, given tracked is a helper that increases a counter and return the value of Name.

sunng87 avatar Feb 15 '23 13:02 sunng87