Repository navigation
Allow passing variables defined by assign to include_template. - #141
Merged
SuperCuber merged 1 commit intoAug 14, 2023
Merged
Conversation
This change allows using the `assign` helper from `handlebars_misc_helpers` to pass variables into templates rendered with `include_template`. The `assign` helper modifies the `RenderContext` and previously `include_template` would use the `Context` when rendering the template. The change attempts to use the `RenderContext` with a fallback to use the `Context` if no `RenderContext` exists. Note that this change does not address `handlebars_misc_helpers` SuperCuber#65. The `assign` helper clones the `Context` and overwrites the `RenderContext` on every call meaning that only variables defined by the most recent `assign` call will be available. Resolves SuperCuber#134.
Owner
|
Yeah ideally to test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change allows using the
assignhelper fromhandlebars_misc_helpersto pass variables into templates rendered withinclude_template. Theassignhelper modifies theRenderContextand previouslyinclude_templatewould use theContextwhen rendering the template. The change attempts to use theRenderContextwith a fallback to use theContextif noRenderContextexists.Note that this change does not address
handlebars_misc_helpers#65. Theassignhelper clones theContextand overwrites theRenderContexton every call meaning that only variables defined by the most recentassigncall will be available.Resolves #134.
@SuperCuber, thanks for your time so far. I've put this PR together assuming no changes are made in
handlebars_misc_helpers. I didn't add any tests because external test template files would be needed and wasn't sure how you would want those organized. Let me know if you want me to revisit this. I'm also not sure how long you want to wait on feedback on davidB/handlebars_misc_helpers#65.