addMacro() public method

Adds new macro with IMacro flags.
public addMacro ( $name, latte\IMacro $macro, $flags = NULL ) : static
$macro latte\IMacro
return static
示例#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;
 }
 public static function install(Compiler $compiler)
 {
     $ifAllowedHrefMacro = new static($compiler);
     $compiler->addMacro('ifAllowedHref', $ifAllowedHrefMacro);
     $compiler->addMacro('allowedHref', $ifAllowedHrefMacro);
 }