Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Nested if else in Twig

elseif needs to be single word tag/keyword and expression shouldn’t have parenthesis same as if expression.

http://twig.sensiolabs.org/doc/tags/if.html

<body
    {% if page|default('login') == 'login' %}
          class="login"
    {% elseif page == 'other' %}
          class="login"
    {% else %}
          class="noclass"
    {% endif %}>
</body>

Related Posts:

  1. What is the difference between .yaml and .yml extension? [duplicate]
  2. webpack: Cannot read property ‘match’ of undefined
  3. “If not” condition statement in python
  4. Check if something is (not) in a list in Python
  5. How do I use properly CASE..WHEN in MySQL
  6. How to center text with Markdown?
  7. Python conditional assignment operator
  8. Inline conditions in Lua (a == b ? “yes” : “no”)?
  9. Don’t understand this SyntaxError: illegal target for annotation
  10. HTML IF Statement
  11. when to use if vs elif in python
  12. SQL conditional SELECT
  13. Conditional JOIN Statement SQL Server
  14. (Excel) Conditional Formatting based on Adjacent Cell Value
  15. Clear cache in Symfony: `cache:clear` or `rm -rf`?
Categories symfony Tags conditional, symfony, twig
What is the difference between String.slice and String.substring?
How to open a URL in a new Tab using JavaScript or jQuery?

Leave a Comment Cancel reply

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress