-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
Feature: dynamic CSS classes with Hash #813
Comments
I don't think it is a good idea to complicate the Slim syntax for this feature, given that you can simply use a function like the |
Thanks for taking the time to reply. Since then, I've considered another approach: Spone#1 |
This sounds like a useful generalization. My suggestion would be to make |
Thank you! I'll try to get back to it! |
Just to clarify, do you mean having: Slim::Parser.options[:shortcut].update({
'~' => { attr: ->(v) { ["class", "styles['#{v}']"] } }
}) instead of: Slim::Parser.options[:shortcut].update({
'~' => { attr: "class", attr_value: ->(v) { "styles['#{v}']" } }
}) |
Yes. This generalizes |
Hello,
I'd like to suggest a new feature. The idea would be to allow generating CSS classes dynamically based on a Hash:
div(class={one: true, two: false, three: true})
would render:
<div class="one three"></div>
I currently use this gem for that: https://github.com/komposable/klassnames but it would be great to have this feature included in Slim!
Let me know what you think.
The text was updated successfully, but these errors were encountered: