Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Created December 16, 2013 22:23
Show Gist options
  • Save donmccurdy/7995539 to your computer and use it in GitHub Desktop.
Save donmccurdy/7995539 to your computer and use it in GitHub Desktop.
$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