Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11816

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

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev
    • Fix Version/s: 3.1.0-a1
    • Component/s: Template Engine
    • Labels:
      None

      Description

      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 "$"
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: