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

Add attr_value support to shortcuts #1

Closed
wants to merge 2 commits into from
Closed

Conversation

Spone
Copy link
Owner

@Spone Spone commented Apr 9, 2021

Related discussion: ViewComponent/view_component#677 (comment)

NOTE: This is a quick & dirty test! It should be refactored and tested before opening a PR against upstream.

This creates an attr_value param for shortcuts. You can pass it a Proc that will be called when the tag is parsed.

Slim::Parser.options[:shortcut].update({
  '~' => { attr: "class", attr_value: ->(v) { "styles['#{v}']" } }
})

Then in your slim template you can do:

~text Lorem ipsum
/ <div class="Styled_6c266_text">Lorem ipsum</div>

p~text.is-big LOREM IPSUM
/ <p class="Styled_6c266_text is-big">LOREM IPSUM</p>

@Spone
Copy link
Owner Author

Spone commented Jan 23, 2023

Replaced by slim-template#903

@Spone Spone closed this Jan 23, 2023
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.

1 participant