[TASK] Fluid (Core): Formatted Regular Expressions more nicely
authorSebastian Kurfürst <sebastian@typo3.org>
Thu, 26 Aug 2010 08:13:10 +0000 (08:13 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Thu, 26 Aug 2010 08:13:10 +0000 (08:13 +0000)
There were some undocumented regular expressions
in the parser, which needed to be formatted nicely.

typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php

index 8d65f6c..970bc2c 100644 (file)
@@ -60,7 +60,27 @@ class Tx_Fluid_Core_Parser_TemplateParser {
         *
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public static $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG = '/^<(?P<NamespaceIdentifier>NAMESPACE):(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)(?P<Attributes>(?:\s*[a-zA-Z0-9:]+=(?:"(?:\\\"|[^"])*"|\'(?:\\\\\'|[^\'])*\')\s*)*)\s*(?P<Selfclosing>\/?)>$/';
+       public static $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG = '/
+               ^<                                                # A Tag begins with <
+               (?P<NamespaceIdentifier>NAMESPACE):               # Then comes the Namespace prefix followed by a :
+               (?P<MethodIdentifier>                             # Now comes the Name of the ViewHelper
+                       [a-zA-Z0-9\\.]+
+               )
+               (?P<Attributes>                                   # Begin Tag Attributes
+                       (?:                                           # A tag might have multiple attributes
+                               \s*
+                               [a-zA-Z0-9:]+                             # The attribute name
+                               =                                         # =
+                               (?:                                       # either...
+                                       "(?:\\\"|[^"])*"                      # a double-quoted string
+                                       |\'(?:\\\\\'|[^\'])*\'                # or a single quoted string
+                               )                                         #
+                               \s*
+                       )*                                            # A tag might have multiple attributes
+               )                                                 # End Tag Attributes
+               \s*
+               (?P<Selfclosing>\/?)                              # A tag might be selfclosing
+               >$/x';
 
        /**
         * This regular expression scans if the input string is a closing ViewHelper
@@ -75,7 +95,21 @@ class Tx_Fluid_Core_Parser_TemplateParser {
         *
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public static $SPLIT_PATTERN_TAGARGUMENTS = '/(?:\s*(?P<Argument>[a-zA-Z0-9:]+)=(?:(?P<ValueQuoted>(?:"(?:\\\"|[^"])*")|(?:\'(?:\\\\\'|[^\'])*\')))\s*)/';
+       public static $SPLIT_PATTERN_TAGARGUMENTS = '/
+               (?:                                              #
+                       \s*                                          #
+                       (?P<Argument>                                # The attribute name
+                               [a-zA-Z0-9:]+                            #
+                       )                                            #
+                       =                                            # =
+                       (?:                                          # obsolete I guess
+                               (?P<ValueQuoted>                         # either...
+                                       (?:"(?:\\\"|[^"])*")                 # a double-quoted string
+                                       |(?:\'(?:\\\\\'|[^\'])*\')           # or a single quoted string
+                               )
+                       )\s*
+               )
+               /xs';
 
        /**
         * This pattern detects CDATA sections and outputs the text between opening