Latte\Compiler::addMacro PHP 메소드

addMacro() 공개 메소드

Adds new macro with IMacro flags.
public addMacro ( $name, latte\IMacro $macro, $flags = NULL ) : static
$macro latte\IMacro
리턴 static
    public function addMacro($name, IMacro $macro, $flags = NULL)
    {
        if (!isset($this->flags[$name])) {
            $this->flags[$name] = $flags ?: IMacro::DEFAULT_FLAGS;
        } elseif ($flags && $this->flags[$name] !== $flags) {
            throw new \LogicException("Incompatible flags for macro {$name}.");
        }
        $this->macros[$name][] = $macro;
        return $this;
    }

Usage Example

예제 #1
0
 public function addMacro($name, $begin, $end = NULL, $attr = NULL, $flags = NULL)
 {
     if (!$begin && !$end && !$attr) {
         throw new \InvalidArgumentException("At least one argument must be specified for macro '{$name}'.");
     }
     foreach ([$begin, $end, $attr] as $arg) {
         if ($arg && !is_string($arg)) {
             Latte\Helpers::checkCallback($arg);
         }
     }
     $this->macros[$name] = [$begin, $end, $attr];
     $this->compiler->addMacro($name, $this, $flags);
     return $this;
 }
All Usage Examples Of Latte\Compiler::addMacro