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

Add support for dynamic template options v1x #155

Merged

Conversation

allouis
Copy link
Collaborator

@allouis allouis commented Apr 2, 2019

This is a duplicate of #154 - but for the v1.x branch

This also installs lodash, so that we have access to the _.merge function used to join the local template options with the global ones.


Currently template options are global for a single ExpressHbs instance. They are set through the updateTemplateOptions method.

This PR adds support for "local" template options so that they can be configured on a request by request basis.

The renderTemplate function now reads the _templateOptions property from res.locals and merges those with the global template options before passing them to the template to be rendered.

There are 2 new methods on ExpressHbs to abstract over getting and setting the _templateOptions property on a locals object - so it can be changed in the future.

@allouis allouis merged commit ebb6112 into TryGhost:v1.x Apr 3, 2019
@allouis allouis deleted the add-support-for-dynamic-template-options-v1x branch April 3, 2019 09:06
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.

1 participant