Feature #89981

Trim identifier spaces in core IconViewHelper

Added by Oliver Hader 11 months ago. Updated 8 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
Category:
Fluid
Start date:
2019-12-17
Due date:
% Done:

0%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

<core:icon identifier="actions-version-document-remove           " size="small" />

History

#1 Updated by Oliver Hader 11 months ago

  • Assignee set to Oliver Hader

#2 Updated by Oliver Hader 11 months ago

  • Subject changed from Trim spaces in core IconViewHelper to Trim identifier spaces in core IconViewHelper

#3 Updated by Guido Schmechel 10 months ago

Maybe I also misunderstand the request. But don't we have to include trim() in all ViewHelper for all arguments? What makes this field so special? Comparable to me is the ImageViewHelepr with src.

#4 Updated by Georg Ringer 10 months ago

  • Status changed from New to Needs Feedback

#5 Updated by Oliver Hader 10 months ago

I agree that this should be tackled in other view helpers as well - probably not in "all", but in a lot...

#6 Updated by Georg Ringer 8 months ago

  • Tracker changed from Bug to Feature
  • Target version set to Candidate for Major Version

I guess there should be a new property trimArguments which could be default on and if someone needs those spaces, it needs to be disabled. This way we don't need to tackle every VH. what do you think?

switching this to feature

#7 Updated by Claus Due 8 months ago

Note that this argument is not a tag attribute that is output and only has impact internally in affected ViewHelpers.

It would not be feasible to implement a "trimArguments" property to solve this use case:

  • Implementing it per-argument would require an API change in Fluid which would be breaking meaning it would only happen for Fluid 3.0 and above.
  • Implementing a general "trimArguments" property would require a base class in TYPO3 CMS which no longer exists.
  • Generally speaking it would not be safe to universally trim string arguments.
  • Fluid behaves explicitly concerning strings: what you pass is what you receive.

The more appropriate solution is to internally use trim() on the argument only in cases where this may be likely to happen. Or document that it is improper practice to add whitespace in such argument values since the value is received verbatim.

On a side note, this use case is probably unlikely to occur in the wild, since the argument only supports a single value - unlike for example "class" which is far more likely to contain a value like "{class1} {class2}" where we would indeed like to trim away any whitespaces if either of the variables are empty. However, trimming the value in this use case has no impact on browser interpretation of the attribute and is therefore redundant.

My personal recommendation would be the close the issue and avoid the described syntax for ViewHelpers that use the argument value as input for other methods - and preserve the verbatim passing of argument value in template as real value for the argument in PHP.

Also available in: Atom PDF