Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Handlebars 3.0 #105

Merged
merged 5 commits into from
Mar 22, 2015
Merged

Upgrade to Handlebars 3.0 #105

merged 5 commits into from
Mar 22, 2015

Conversation

ericf
Copy link
Owner

@ericf ericf commented Feb 12, 2015

This upgrades to Handlebars 3.0 and makes backwards-incompatible changes to the ExpressHandlebars API. Since Handlebars had a major version bump, it seemed appropriate for this package to have a major version bump as well, so I took the liberty of refactoring some things.

  • Add compilerOptions config property which is passed along to Handlebars.compile() and precompile().
  • Expose ExpressHandlebars metadata to the data channel during render (Inject more data to handlebars during render #101). This metadata is accessibile via {{@exphbs.*}}
  • New "protected" hooks for AOP-ing template compilation and rendering, all of which can optionally return a Promise:
    • _compileTemplate()
    • _precompileTemplate()
    • _renderTemplate()

For most apps this will be a drop-in replacement to v1 of this package, and using Handlebars 3.0 should be a drop-in replacement as well. That said, here's the changes that potentially break back-compat:

  • Removed using prototype props for default config values.
  • Removed handlebarsVersion from instances and getHandlebarsSemver static function on the ExpressHandlebars constructor.
  • Replaced undocumented compileTemplate() hook with the protected but supported _compileTemplate() and _precompileTemplate() hooks.

This upgrades to Handlebars 3.0 and makes backwards-incompatible
changes to the ExpressHandlebars API. Since Handlebars had a major
version bump, it seemed appropriate for this package to have a major
version bump as well, so I took the liberty of refactoring some things.

- Add `compilerOptions` config property which is passed along to
  `Handlebars.compile()` and `precompile()`.

- Expose ExpressHandlebars metadata to the `data` channel during
  render (#101). This metadata is accessibile via
  `@data.ExpressHandlebars.*`

- New "protected" hooks for AOP-ing template compilation and rendering,
  all of which can optionally return a Promise:

  - `_compileTemplate()`
  - `_precompileTemplate()`
  - `_renderTemplate()`

For most apps this will be a drop-in replacement to v1 of this package,
and using Handlebars 3.0 should be a drop-in replacement as well. That
said, here's the changes that potentially break back-compat:

- Removed using `prototype` props for default config values.

- Removed `handlebarsVersion` from instances and `getHandlebarsSemver`
  static function on the `ExpressHandlebars` constructor.

- Replaced undocumented `compileTemplate()` hook with the protected but
  supported `_compileTemplate()` and `_precompileTemplate()` hooks.
@dominicbarnes
Copy link

One more request, {{@ExpressHandlebars.*}} is really verbose.. could you make the name a bit shorter? Maybe something like exphbs since that acronym is used elsewhere?

It's not a huge deal, maybe you could just make that property name configurable?

@ericf
Copy link
Owner Author

ericf commented Feb 13, 2015

One more request, {{@ExpressHandlebars.*}} is really verbose.. could you make the name a bit shorter? Maybe something like exphbs since that acronym is used elsewhere?

Yeah it is, I'll sleep on it. exphbs seems like the top candidate.

It's not a huge deal, maybe you could just make that property name configurable?

I'd rather not add an option for this but instead keep it fixed, at least for now. So if the reason you want it configurable is to have a shorter name, I'd rather just change the name before I cut the release 😄

@dominicbarnes
Copy link

Thanks!

Yeah, I just wanted the shorter name. Not to mention, having it capitalized like that just sticks out like a sore thumb in the apps I write. :P

@ericf
Copy link
Owner Author

ericf commented Feb 17, 2015

I will be merging this in the next couple of days, so if anyone has feedback let me know.

@ericf ericf mentioned this pull request Mar 3, 2015
@adon-at-work
Copy link

any timeline when it'll be merged to master? :)

@ericf
Copy link
Owner Author

ericf commented Mar 16, 2015

@adon-at-work I hope to find time to finish this by updating the README docs and publishing to npm today.

@adon-at-work
Copy link

OK. Thanks.

ericf added a commit that referenced this pull request Mar 22, 2015
@ericf ericf merged commit 8e3c92a into master Mar 22, 2015
@ericf ericf deleted the handlebars-3.0 branch March 22, 2015 18:50
@ericf
Copy link
Owner Author

ericf commented Mar 23, 2015

Released as v2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants