src/View/SSTemplateParser.php
public function compileString($string, $templateName = "", $includeDebuggingComments = false, $topTemplate = true)
    {
        if (!trim($string)) {
            $code = '';
        } else {
            parent::__construct($string);

            $this->includeDebuggingComments = $includeDebuggingComments;

            // Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
            // (and other encodings) properly
            if (substr($string, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
                $this->pos = 3;
            }

            // Match the source against the parser
            if ($topTemplate) {
                $result = $this->match_TopTemplate();
            } else {
                $result = $this->match_Template();
            }
            if (!$result) {
                throw new SSTemplateParseException('Unexpected problem parsing template', $this);
            }

            // Get the result
            $code = $result['php'];
        }

        // Include top level debugging comments if desired
        if ($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
            $code = $this->includeDebuggingComments($code, $templateName);
        }

        return $code;
    }
public function compileString($string, $templateName = "", $includeDebuggingComments = false, $topTemplate = true)
    {
        if (!trim($string)) {
            $code = '';
        } else {
            parent::__construct($string);

            $this->includeDebuggingComments = $includeDebuggingComments;

            // Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
            // (and other encodings) properly
            if (substr($string, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
                $this->pos = 3;
            }

            // Match the source against the parser
            if ($topTemplate) {
                $result = $this->match_TopTemplate();
            } else {
                $result = $this->match_Template();
            }
            if (!$result) {
                throw new SSTemplateParseException('Unexpected problem parsing template', $this);
            }

            // Get the result
            $code = $result['php'];
        }

        // Include top level debugging comments if desired
        if ($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
            $code = $this->includeDebuggingComments($code, $templateName);
        }

        return $code;
    }
public function compileString ( $ string , $ templateName = "" , $ includeDebuggingComments = false , $ topTemplate = true ) { if ( ! trim ( $ string ) ) { $ code = '' ; } else { parent :: __construct ( $ string ) ; $ this -> includeDebuggingComments = $ includeDebuggingComments ; // Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF // (and other encodings) properly if ( substr ( $ string , 0 , 3 ) == pack ( "CCC" , 0xef , 0xbb , 0xbf ) ) { $ this -> pos = 3 ; } // Match the source against the parser if ( $ topTemplate ) { $ result = $ this -> match_TopTemplate ( ) ; } else { $ result = $ this -> match_Template ( ) ; } if ( ! $ result ) { throw new SSTemplateParseException ( 'Unexpected problem parsing template' , $ this ) ; } // Get the result $ code = $ result [ 'php' ] ; } // Include top level debugging comments if desired if ( $ includeDebuggingComments && $ templateName && stripos ( $ code , "<?xml" ) === false ) { $ code = $ this -> includeDebuggingComments ( $ code , $ templateName ) ; } return $ code ; }
Compiles some passed template source code into the php code that will execute as per the template source.

@throws SSTemplateParseException
@param string $string The source of the template
@param string $templateName The name of the template, normally the filename the template source was loaded from
@param bool $includeDebuggingComments True is debugging comments should be included in the output
@param bool $topTemplate True if this is a top template, false if it's just a template
@return mixed|string The php that, when executed (via include or exec) will behave as per the template source
Compiles some passed template source code into the php code that will execute as per the template source .