-
Notifications
You must be signed in to change notification settings - Fork 404
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
Fix inline component throws error with strip_trailing_whitespace #2015
Conversation
@Spone I have simplified the failing test with while keeping the same error |
it seems strip_trailing_whitespace doesn't work with inline templates, I have created a fix locally that seem to work, I will push it up latter |
Awesome, that's really useful! |
@Spone I have updated the description, to reflect the actual bug, I then also fixed the test and have added the fix for the bug |
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.
Pretty elegant solution! Can we make sure that it doesn't affect performance?
@Spone I write a benchmark by rewriting the old performance inline_componet on a new component and testing that, it seems this is actually faster by a small margin see the description for more details |
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 makes sense to me, thanks @reeganviljoen!
closes #2013
What are you trying to accomplish?
Inline components throws
when strip_trailing_whitespace is used, so this is an attempt to make
strip_trailing_whitespace
behave in inline components as they do for normal componentsWhat approach did you choose and why?
I removed
template.rstrip! if component_class.strip_trailing_whitespace?
as the template object is aViewComponent::InlineTemplate::Template
and not a stringI then added
template = template.source.dup
so tat the template string could be unfrozen for compile_template to remove the trailing white spacePerformance Imapct
before change
After