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

[symfony-toggle] Twig extension #32

Closed
ajgarlag opened this issue Oct 17, 2022 · 1 comment · Fixed by #36
Closed

[symfony-toggle] Twig extension #32

ajgarlag opened this issue Oct 17, 2022 · 1 comment · Fixed by #36
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@ajgarlag
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Sometimes, the check for a feature is required only to display or not some elements in a template. So if more than one controller renders the same template, I need to set the same boolean variable in every controller.

Describe the solution you'd like
I'd like to have some twig function or test to check if the feature is enabled without modifying the controller code.

Describe alternatives you've considered
I'd like to have a twig extension providing one function:

{# the second and third parameters are optional #}
{% if is_feature_enabled('feature_name', 'id', {payload_item1: payload_item_value1, payload_item2: payload_item_value2}) %}

{% endif %}

and two tests:

{% if 'feature_name' is enabled %}
    ...
{% endif %}
{% if 'feature_name' is enabled for(identity_object)%}
    ...
{% endif %}

Additional context
Would you accept a PR implementing this?

@ajgarlag ajgarlag added the question Further information is requested label Oct 17, 2022
@kpicaza
Copy link
Member

kpicaza commented Oct 17, 2022

Hello @ajgarlag, thanks for your question. I really like it. It would be a nice improvement for the developer experience in any app involving twig templates.

I think the only drawback for a possible implementation is to take care of adding the extension only when Twig is available in the Symfony container. Twig isn't a library requirement, so, we can set it as a dev dependency. This way we can have the twig extension when twig is enabled. Also, continue working on applications that don't use the Twig engine.

If you have questions, don't hesitate to ask, I'll be happy to answer any question and help in any doubt. Thanks for contributing, and Welcome to our Community.

@kpicaza kpicaza added the enhancement New feature or request label Oct 17, 2022
@kpicaza kpicaza changed the title Twig extension [symfony-toggle] Twig extension Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants