Created
December 16, 2013 22:23
-
-
Save donmccurdy/7995539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$token = $stream->readToken(); | |
if (strpos($token, '=') === 0) { | |
// Evaluate {{= field*2}} | |
$output .= $this->expression_parser->evaluate(substr($token, 1)); | |
} else if (preg_match('/^#([\S]+)(?:[\s]+)([^\}\}]+)/', $token, $match)) { | |
// Block {{#blockType blockArg}} | |
$output .= $this->renderBlock($stream, $match[1], $match[2]); | |
} else if (preg_match('/^phrase(?:[\s]+)([\S]+)(?:[\s]+)([\S]+)/', $token, $match)) { | |
// Phrase {{phrase field switchID}} | |
$output .= $this->renderPhrase($match[1], $match[2]); | |
} else if (strpos($token, '!') === 0) { | |
; // Comment | |
} else if (preg_match('/^([\S]+)(?:[\s]+)([\S]+)/', $token, $match)) { | |
// A/an, plural, possessive, etc. | |
$output .= $this->scopes[0]->evaluateScopeFunction($match[1], $match[2]); | |
} else if (preg_match('/^[\S]+$/', $token)) { | |
// Standard Token | |
$output .= $this->scopes[0]->parseToken($token); | |
} else { | |
throw new Exception("I don't know what '$token' means."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment