-
-
Notifications
You must be signed in to change notification settings - Fork 96
Comma-separated tokens #904
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
Conversation
lib/phlex/sgml/elements.rb
Outdated
img: <<~RUBY, | ||
if (tokens = attributes[:srcset]) | ||
attributes[:srcset] = __nested_tokens__(tokens, ", ") | ||
end | ||
RUBY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The technique here is to generate specifically optimised code to check and pre-process the comma-separated-lists before caching takes place. We could cache this step separately but I don’t think it’s worth it.
@@ -23,6 +56,7 @@ def #{method_name}(**attributes) | |||
if block_given # with content block | |||
buffer << "<#{tag}" | |||
begin | |||
#{COMMA_SEPARATED_TOKENS[method_name]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This outputs nothing for most elements and otherwise outputs the code to pre-process one or two values if they exist before caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. I like this approach a lot. It's nice that it only adds the overhead to elements that may use it. I left a few typo fixes.
Implementation of #882