If Statement
The If Statement in Ahmed Template Engine for INEX SPA allows you to conditionally render content based on logical expressions, similar to traditional PHP if-statements but in a cleaner, template-friendly syntax.
Syntax
Example:
This will display the welcome message only if the $user
variable is set.
Else Condition
To execute alternative code when the condition is false, use @else
:
Else If (@elseif
)
@elseif
)For multiple conditions, use @elseif
:
Nested If Statements
You can nest @if
statements for more complex logic:
Using Logical Operators
You can use logical operators in conditions:
Conclusion
The If Statement in Ahmed Template Engine provides a simple and efficient way to control content visibility based on conditions, making templates more dynamic and user-friendly.
Last updated