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

Multiple classes from variables names #2073

Closed
m0onspell opened this issue Nov 15, 2016 · 4 comments
Closed

Multiple classes from variables names #2073

m0onspell opened this issue Nov 15, 2016 · 4 comments
Labels

Comments

@m0onspell
Copy link

m0onspell commented Nov 15, 2016

I have to keep my class names in variables, and following won't work:

<some-tag>
  <div class={classes['first-class']: true, classes['second-class']: true}></div>
  <script type="babel">
    this.classes = opts.classes;
  </script>
</some-tag>

I can create a mixin function to concat those classes, but is there any native way to have multiple classes from variables names?

@cognitom
Copy link
Member

cognitom commented Nov 15, 2016

Hi @m0onspell, try this simply:

<div class="{classes['first-class']} {classes['second-class']}"></div>

FYI, Computed property names is introduced in es6, but I think it's not supported in Riot yet. And even if it was supported, {classes['first-class']: true} doesn't make sense. It would be {[classes['first-class']]: true}.

@m0onspell
Copy link
Author

@cognitom thank you.
Yeah, I know, I just wanted to demonstrate the general idea.

@m0onspell
Copy link
Author

One note: you shouldn't use , just

<div class="{classes['first-class']} {classes['second-class']}"></div>

@cognitom
Copy link
Member

Oh, right. I've fixed the comment above. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants