-
Notifications
You must be signed in to change notification settings - Fork 93
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
Feature request: Allow tags to be excluded from rendering / Global Fluid-parameters #430
Comments
FYI, this could be rewritten using a partial/section:
Still rather verbose but reduces code duplication. |
That's a good idea to reduce duplication. I still don't think it's easy to read but that's for sure the best way right now. I'll update my initial post. |
Renamed the attribute from
|
Hi @jonaseberle - I understand the use case, but While this might be possible to implement as a shared feature for tag-based ViewHelpers, even that comes with an array of problems:
I would argue that it is not the default use case to want this capability, but more or less only makes sense in context of links (that show text without tag). It is also excessively easy to implement in a tag-based ViewHelper on a case-to-case basis (by simply not building the tag but returning the output of render closure instead). So while it might be nice to have when the use case does arise, I really don't think it makes enough sense in a broader context to enable this on every tag-based ViewHelper. Did you consider:
|
Thank you for the code snippet. If you have the content as variable, that might help. I do not agree with your judgement, though.
https://github.com/TYPO3-CMS/fluid_styled_content/blob/master/Resources/Private/Templates/Table.html
|
@jonaseberle Thanks for the examples. For clarity I will go through each one of them, hopefully that illustrates why I make the judgements I make: This structure can be cleaned up very significantly by using variable assignments to store the image/tag and conditionally wrapping it using the method I suggested. Additionally, @mbrodala's suggestion about sections to do wrapping also applies (combine that with my code piece for an even more compact structure). This is not the right way to write a Fluid template and it only works because there is no Fluid code inside those conditions before/after the loop. This should absolutely without question be refactored to conditional wrapping using a section or partial. This template can be sanitised and compacted in several ways:
Identical to "textpic".
I agree this template is pretty bad but every suggestion given above actually applies in this template as well. I do not disagree with you that these templates aren't ideal, but you should be aware that they were written very long ago and don't use the appropriate Fluid features that were created exactly to combat the problems you described. The links aren't so much a complaint against Fluid - rather, a complaint against Keeping this new information in mind, could you specify what you disagree with about my judgement? Perhaps we're not completely understanding each other about the "standard case" way of putting it. What I mean is simply that it's not in my opinion reasonable to build a feature into each and every TagBasedViewHelper and by doing so, creating breaking incompatibilities in render methods, to solve a use case that's relevant for perhaps 1% of templates - if that much. |
Ok, lets make pull requests to fluid_styled_content and see where we go from there. So to at least have good examples in any default TYPO3 installation ;) I'll see how I find time. |
I often feel the need to only render a tag based on conditions, but render its contents anyways.
A simple example would be content that might be needed to be wrapped in a link or not.
To recreate this logic in Fluid, currently the best way seems:
Nota bene: Workarounds like
are making things complex to read and write and are not sane IMHO. But even given that this is incredibly ugly it is actually used thus proving my point that this use case is very common.
Wouldn't it be a lot easier if I could do
?
I envision this for any tag (not just Fluid-tags), e.g.
So something global, not just an additional ViewHelper-parameter to have it really flexible.
Examples for templating languages where I have seen and learnt to love similar are ZPT (
tal:condition
https://zope.readthedocs.io/en/latest/zope2book/ZPT.html#conditional-elements andtal:omit-tag
) and JSF (therendered=
parameter).What do you think? Any ideas?
The text was updated successfully, but these errors were encountered: