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

Rewriting include tag to properly match liquid source #12

Merged
merged 3 commits into from
Mar 16, 2017

Conversation

ianmburns
Copy link

cc @joshua @mgolus @mattbronkema

When we first wrote the additional code for the 'with' and 'for' modifiers on the include tags, we were a bit off with our mapping. We were treating any maps as the main context instead of the include template name as the context key with the map as the value.

Examples

Context:
{item = {address = {city: Charleston, state: SC}}
item.address.city = "Charleston"

{include 'address.liq' with item.address}

Include Context:

Old:
{city: Charleston, state: SC}
city = "Charleston"

New:
{address = {City: Charleston, State: SC}}
address.city = "Charleston"

See https://github.com/Shopify/liquid/blob/master/lib/liquid/tags/include.rb#L58 for example of implementation. I tried to replicate the fall through of "isarray" by allowing the context to be set even if we did not support the array type.

tags/include.go Outdated
}
}

return core.Normal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianmburns Should the return core.Normal be inside the switch statement?

Copy link

@thecitydeployer thecitydeployer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ianmburns ianmburns merged commit 5bcb5c9 into master Mar 16, 2017
@ianmburns ianmburns deleted the feature/include-refactor branch March 16, 2017 12:08
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.

None yet

4 participants