Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-11816

Twig regression: parentheses in IF statements stop DEFINE variables and loop lengths from working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.1.0-a1
    • 3.1.0-dev
    • Template Engine
    • None

      According to the coding guidelines on IF statements in templates, "basic parenthesis can also be used to enforce good old BODMAS rules." However, using parentheses with the new twig templating engine makes it choke on statements like these:

      <!-- IF not ($A or $B) --><!-- ENDIF -->
      <!-- IF X and (.loopvar or Y) --><!-- ENDIF -->
      

      This is because the regexes that look for the dollar sign and the period require whitespace directly before. A workaround is therefore:

      <!-- IF not ( $A or $B) --><!-- ENDIF -->
      <!-- IF X and ( .loopvar or Y) --><!-- ENDIF -->
      

      This breaks normal coding style, however, and twig doesn't exactly fail gracefully on omitting this workaround:

      Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unexpected character "$"
      

            EXreaction EXreaction [X] (Inactive)
            rechosen rechosen [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: