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 documentation apply.rst #3946

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

dylan-b-efficience-it
Copy link

Add documentation for twig filters compatible with tag apply tag uses

@stof
Copy link
Member

stof commented Dec 15, 2023

This does not make sense to me: all filters that operate on strings are compatible (including any third-party filter fitting this). And when chaining filters, this actually applies to the first filter of the chain (next filters have to operate on the output of the previous one).

@dylan-b-efficience-it
Copy link
Author

There is no indication about 'filters that operates on string' in the documentation about apply, there is neither a list to reference them globally.
That's the reasoning behind my listing of filters working in this particular case.

@stof
Copy link
Member

stof commented Dec 15, 2023

But this list will also be incomplete: extensions can provide lots of filters, and apply won't restrict them.

This restriction about filters applying on strings is just because apply passes the result of rendering its body as input to the filter (and this result is a string).

And even if we do a list, we should not have examples for all of them (with broken rST markup for all of them that will break the rendering on the website, and wrong comments about the output for some of them), that don't provide a full documentation about that. If such a list is added, it should link to the documentation of each filter.

Also, this seems to miss half of the filters that apply on strings among the list available in https://twig.symfony.com/doc/3.x/#reference (and some more if we account for the filters provided by Symfony, which are listed below)

@dylan-b-efficience-it
Copy link
Author

I understand your point.
In this case, I think that in the apply documentation, it should simply be stated that because we're processing a block of text, only string-based filters can be applied.
It should make the filter easier to handle.

@dylan-b-efficience-it
Copy link
Author

@stof
I've modified the documentation accordingly to indicate that the "apply" tag can only be applied to filters that return a string.

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

Successfully merging this pull request may close these issues.

None yet

2 participants