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

Dynamic data tag attributes #168

Closed
developer1031 opened this issue Sep 30, 2020 · 1 comment
Closed

Dynamic data tag attributes #168

developer1031 opened this issue Sep 30, 2020 · 1 comment

Comments

@developer1031
Copy link

How could I convert below erb to slim?

ERB code

<div class="click" <%= love_type ? "data-review=#{target}" : "data-recommend=#{target}" %>
                                   data-logined='<%= sth%>'></div>

I tried...

.click[data-logined="#{sth}"
      love_type ? data-review="#{target}" : data-recommend="#{target}"]

and

.click data-logined="#{sth}" love_type ? data-review="#{target}" : data-recommend="#{target}"

But not work...

How could I do this writing simple DRY code?

@developer1031
Copy link
Author

developer1031 commented Oct 2, 2020

https://stackoverflow.com/questions/64133581/rails-slim-dynamic-data-tag-attributes/64133966#64133966

I prefer more dynamic way but not worse either.

Works like charm!~

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

No branches or pull requests

1 participant