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

Support rendering symbols as strings #920

Merged
merged 1 commit into from
Aug 18, 2017
Merged

Support rendering symbols as strings #920

merged 1 commit into from
Aug 18, 2017

Conversation

pushrax
Copy link
Contributor

@pushrax pushrax commented Aug 17, 2017

Fixes #919

@pushrax pushrax requested a review from fw42 August 17, 2017 18:56
@@ -7,6 +7,12 @@ def to_liquid
end
end

class Symbol # :nodoc:
def to_liquid
self
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to have to deal with the difference between symbols and strings in filters and tags? Or should we use to_s here so that symbols get converted into strings and we don't have to worry about another possible type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fairly sure that everything that expects a string does to_s already. This is definitely the case in StandardFilters. (also Symbol#size == Symbol#to_s.size)

If you think it would be better to to_s here though, I considered that also and am not against it.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few type checks for String in lib/liquid/utils.rb which won't match for a Symbol, however, the distinction is probably more likely to affect application code.

I think that doing to_s would be better to do here if we never want to treat Symbol as being different from String. That seems like it would be better for keeping the language simpler and to avoid having to worry about the edge case of a Symbol being assigned to a variable.

@pushrax pushrax merged commit 44eaa4b into master Aug 18, 2017
@pushrax pushrax deleted the symbol_to_liquid branch August 18, 2017 16:10
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

3 participants