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

[RFC] Added support for classes function #2797

Open
lyrixx opened this Issue Jan 8, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@lyrixx
Copy link
Contributor

lyrixx commented Jan 8, 2019

The classes function in javascript is quite useful.
Do you think it could be in twig ?
I would port it if you want

@yceruto

This comment has been minimized.

Copy link
Contributor

yceruto commented Jan 8, 2019

Yes, that's something we need often! I did it for some apps in another way, by adding a custom filter |filter (for PHP: array_filter()) in combination with |keys|join(' '), but definitely a built-in function would be quite useful.

I'm guessing something like this:

<div class="{{ class_names({
    'class1': condition1, 
    'class2': condition2,
    'class3': condition3,
}) }}">
    {# ... #}
</div>

@lyrixx lyrixx referenced a pull request that will close this issue Jan 9, 2019

Open

Added support for `classes` function #2798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment