Skip to content

Conversation

iliekturtles
Copy link
Contributor

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 #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 #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.

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.
@SuperCuber
Copy link
Owner

Yeah ideally to test include_template_helper the filesystem mock could be used - but IMO this is good enough.

@SuperCuber SuperCuber merged commit 903a6f3 into SuperCuber:master Aug 14, 2023
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.

[FEATURE] Pass variables/parameters to include_template helper
2 participants