helpers / helper-date

Format dates with date.js and moment.js. Uses date.js to parse human readable date phrases, and moment to format the rendered output. Should work with any Handlebars, Lo-Dash, underscore, or any template engine that allows helper functions to be registered. Also compatible with verb, assemble and Template.
MIT License
6 stars 10 forks source link

Moment breaks when using handlebars-helpers #1

Closed bradtaylorsf closed 7 years ago

bradtaylorsf commented 7 years ago

In the latest version of 1.0.0 on line 16 in index.js, options.hash is referenced, however hash is a property of pattern.

I was able to fix it by replacing options.hash with pattern. I will create a PR to fix.

var opts = Object.assign({}, this, defaults, options, options.hash);

should be

var opts = Object.assign({}, this, defaults, options, pattern);

JSandmark commented 7 years ago

Thank you, I have spent several hours trying to figure this out. Please accept the pull request dear creators!

JSandmark commented 7 years ago

@bradtaylorsf can you use lang-parameter with your fix? {{moment myDate lang="se"}} I cannot pass the lang as it is not set in the helper-date, it defaults to en. I noticed the other issue reported but that does not seem to help me. Any suggestions?

JSandmark commented 7 years ago

Any other comments on this issue? This must affect everyone that uses handlebars-helpers (https://github.com/helpers/handlebars-helpers) with a confusing compile error which ends up in this issue. To manually change the source on production like @bradtaylorsf suggested is not really the best solution. Is there anything I can do to assist with the pull request that is not passing checks?