Latte\PhpWriter::using PHP Method

using() public static method

public static using ( MacroNode $node )
$node MacroNode
    public static function using(MacroNode $node)
    {
        $me = new static($node->tokenizer, NULL, $node->context);
        $me->modifiers =& $node->modifiers;
        return $me;
    }

Usage Example

Beispiel #1
0
 /**
  * New node is found. Returns FALSE to reject.
  *
  * @param MacroNode $node
  * @return bool
  * @throws Latte\CompileException
  */
 public function nodeOpened(MacroNode $node)
 {
     if ($node->prefix) {
         return false;
     }
     if ($node->modifiers) {
         throw new Latte\CompileException("Modifiers are not allowed in {{$node->name}}.");
     }
     $file = $node->tokenizer->fetchWord();
     if ($file === false) {
         throw new Latte\CompileException("Missing file name in {{$node->name}}.");
     } elseif ($node->tokenizer->fetchWord()) {
         throw new Latte\CompileException("Multiple arguments are not supported in {{$node->name}}.");
     }
     $node->isEmpty = true;
     $node->modifiers = '|safeurl|escape';
     // auto-escape
     $writer = Latte\PhpWriter::using($node, $this->compiler);
     if ($this->debugMode) {
         $node->openingCode = $writer->write('<?php echo %modify(%1.word . \'?\' . Nepada\\BustCache\\Helpers::timestamp(%0.var . %1.word)) ?>', $this->wwwDir, $file);
     } elseif (preg_match('#^(["\']?)[^$\'"]*\\1$#', $file)) {
         // Static path
         $file = trim($file, '"\'');
         $url = $file . '?' . Helpers::hash($this->wwwDir . $file);
         $url = Latte\Runtime\Filters::safeUrl($url);
         $node->openingCode = $writer->write('<?php echo %escape(%var) ?>', $url);
     } else {
         $node->openingCode = $writer->write('<?php echo %modify(%1.word . \'?\' . Nepada\\BustCache\\Helpers::hash(%0.var . %1.word)) ?>', $this->wwwDir, $file);
     }
 }
All Usage Examples Of Latte\PhpWriter::using