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

[FEATURE] Support for boolean tag attributes #880

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Jun 25, 2024

TagBasedViewHelpers now have proper support for boolean attributes.
Before this change, it was very cumbersome to generate these with Fluid,
now it's implemented similar to popular JavaScript frameworks:

<my:viewhelper async="{true}" />
Result: <tag async="async" />

<my:viewhelper async="{false}" />
Result: <tag />

<my:viewhelper async="{null}" />
Result: <tag />

This can also be used in combination with variable casting:

<my:viewhelper async="{myString as boolean}" />

For compatibility reasons empty strings still lead to the attribute
being omitted from the tag. This might change in the future, however
we don't want to break templates now. ViewHelpers can define
an argument manually and implement the desired behavior in the
render method (this is how the ImageViewHelper in TYPO3 deals with
empty alt attributes).

@s2b s2b force-pushed the feature/booleanTagAttributes branch 3 times, most recently from 888f67a to 7ec5c3b Compare June 25, 2024 18:54
@s2b
Copy link
Contributor Author

s2b commented Jul 19, 2024

#911

@s2b s2b force-pushed the feature/booleanTagAttributes branch 9 times, most recently from 540e376 to 7a03af5 Compare August 9, 2024 10:00
@s2b s2b changed the title [!!!][FEATURE] Support for boolean tag attributes [FEATURE] Support for boolean tag attributes Aug 9, 2024
@s2b
Copy link
Contributor Author

s2b commented Aug 9, 2024

This PR is based on #949

@s2b s2b force-pushed the feature/booleanTagAttributes branch 2 times, most recently from 29750a7 to 0a5bbc1 Compare August 9, 2024 10:43
@s2b
Copy link
Contributor Author

s2b commented Aug 9, 2024

Test run with TYPO3 core: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85568

@s2b s2b force-pushed the feature/booleanTagAttributes branch from 0a5bbc1 to f3c2ffe Compare August 9, 2024 12:40
@s2b s2b marked this pull request as ready for review August 9, 2024 12:41
TagBasedViewHelpers now have proper support for boolean attributes.
Before this change, it was very cumbersome to generate these with Fluid,
now it's implemented similar to popular JavaScript frameworks:

```
<my:viewhelper async="{true}" />
Result: <tag async="async" />

<my:viewhelper async="{false}" />
Result: <tag />
```

This can also be used in combination with variable casting:

```
<my:viewhelper async="{myString as boolean}" />
```

For compatibility reasons empty strings still lead to the attribute
being omitted from the tag. This might change in the future, however
we don't want to break templates now. ViewHelpers can define
an argument manually and implement the desired behavior in the
render method (this is how the ImageViewHelper in TYPO3 deals with
empty `alt` attributes).
@s2b s2b force-pushed the feature/booleanTagAttributes branch from f3c2ffe to 3b54553 Compare August 9, 2024 12:59
@s2b s2b merged commit 4d5b0c9 into main Aug 9, 2024
8 checks passed
@s2b s2b deleted the feature/booleanTagAttributes branch August 9, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants