Permalink
Browse files

PhpWriter::write() checks for existence of %node.word [Closes #188]

  • Loading branch information...
dg committed Feb 7, 2019
1 parent f0f9b4f commit c1e1f1de7c30f0ec7d06effe5b2c6d53e78e7575
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/Latte/Compiler/PhpWriter.php
@@ -57,7 +57,13 @@ public function write(string $mask, ...$args): string
}, $mask);
$pos = $this->tokens->position;
$word = strpos($mask, '%node_word') === false ? null : $this->tokens->fetchWord();
$word = null;
if (strpos($mask, '%node_word') !== false) {
$word = $this->tokens->fetchWord();
if ($word === null) {
throw new CompileException('Invalid content of macro');
}
}
$code = preg_replace_callback('#([,+]\s*)?%(node_|\d+_|)(word|var|raw|array|args)(\?)?(\s*\+\s*)?()#',
function ($m) use ($word, &$args) {

0 comments on commit c1e1f1d

Please sign in to comment.