Skip to content

Bug: f:else inside f:else always executed #1020

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

Open
linawolf opened this issue Nov 28, 2024 · 1 comment · May be fixed by #1052
Open

Bug: f:else inside f:else always executed #1020

linawolf opened this issue Nov 28, 2024 · 1 comment · May be fixed by #1052

Comments

@linawolf
Copy link
Contributor

TYPO3 11.5 - 13.4

I would have expected, the following would give me an error:

<f:if condition="{link.link_icon_custom}">
	<f:then>
		<span class="link-icon"><i class="{link.link_icon_custom}"></i></span>
	</f:then>
	<f:else>
		<f:if condition="{link.link_icon}">
			<span class="link-icon"><i class="{link.link_icon}"></i></span>
		</f:if>
		<f:else>
			<span class="link-icon"><i class="fas fa-chevron-double-right"></i></span>
		</f:else>
	</f:else>
</f:if>

However the inner else is not only executed but always executed.

@mbrodala
Copy link
Contributor

Notice that the error is not exactly the f:else within f:else but that the 2nd one is not within the 2nd f:if. This would be perfectly valid:

<f:if condition="{link.link_icon_custom}">
	<f:then>
		<span class="link-icon"><i class="{link.link_icon_custom}"></i></span>
	</f:then>
	<f:else>
		<f:if condition="{link.link_icon}">
			<f:then>
				<span class="link-icon"><i class="{link.link_icon}"></i></span>
			</f:then>
			<f:else>
				<span class="link-icon"><i class="fas fa-chevron-double-right"></i></span>
			</f:else>
		</f:if>
	</f:else>
</f:if>

(Yes, this could be optimized to use f:else if="...".)

s2b added a commit that referenced this issue Apr 16, 2025
Before this change, both `f:then` and `f:else` could be used outside of
a condition tag and would then always output the content, regardless
of any condition. Now, nothing is outputted.

In the future, we might consider throwing an exception here to alert the
user about invalid Fluid syntax. However, this would be a breaking change.

Resolves: #1020
@s2b s2b linked a pull request Apr 16, 2025 that will close this issue
s2b added a commit that referenced this issue Apr 16, 2025
Before this change, both `f:then` and `f:else` could be used outside of
a condition tag and would then always output the content, regardless
of any condition. Now, nothing is outputted.

In the future, we might consider throwing an exception here to alert the
user about invalid Fluid syntax. However, this would be a breaking change.

Resolves: #1020
s2b added a commit that referenced this issue Apr 17, 2025
Before this change, both `f:then` and `f:else` could be used outside of
a condition tag and would then always output the content, regardless
of any condition. Now, nothing is outputted.

In the future, we might consider throwing an exception here to alert the
user about invalid Fluid syntax. However, this would be a breaking change.

Resolves: #1020
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 a pull request may close this issue.

2 participants