formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

Missing Variables Raise an Error and Cause the Entire Template to Fail to Render #91

Open doc987 opened 6 years ago

doc987 commented 6 years ago

Normally with Handlebars, a missing variable will result in nothing rendered and no error. For example if there is no variable x, and {{x}} is used in the template, then it will be as if the {{x}} was never included. However, if using an intl helper such as {{formatDate x}} or {{formatNumber x}} and there is no variable x, then an error will be raised, and the entire template will fail to render. Is this intentional? Can the helpers instead just render nothing? Perhaps those functions should start with something like:

if(typeof(arg)=="undefined") return "";