示例#1
0
文件: Filter.php 项目: cseufert/hamle
 function __construct($tag)
 {
     parent::__construct();
     $this->type = ucfirst(strtolower($tag));
     $this->filter = "\\Seufert\\Hamle\\Filter\\{$this->type}";
     if (!class_exists($this->filter)) {
         throw new ParseError("Unable to fild filter {$tag}");
     }
 }
示例#2
0
文件: Form.php 项目: cseufert/hamle
 function __construct($param)
 {
     parent::__construct();
     $param = explode(' ', $param);
     if (count($param) < 2) {
         throw new ParseError("|form requires 2 arguments, form type, and instance");
     }
     $this->var = new H\Text($param[1]);
     if (preg_match('/^(.*)\\((.*)\\)/', $param[0], $m)) {
         $this->form = new $m[1]($m[2]);
     } else {
         $this->form = new $param[0]();
     }
 }
示例#3
0
 function __construct($params)
 {
     parent::__construct();
     if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) {
         throw new Hamle\Exception\ParseError("Unable to parse Snippet({$params})");
     }
     $this->type = $m[1];
     if (isset($m[2])) {
         $this->path = explode(" ", $m[2]);
     } else {
         $this->path = array();
     }
     foreach ($this->path as $k => $v) {
         $this->path[$k] = self::decodeClassId($v);
     }
 }
示例#4
0
 /**
  * Crate new Control Tag
  * @param string $tag Type of Control Tag
  * @param \Seufert\Hamle\Tag $parentTag
  * @throws ParseError
  */
 function __construct($tag, $parentTag = null)
 {
     parent::__construct();
     $this->o = "\$o" . self::$instCount++;
     $this->type = strtolower($tag);
     $this->var = "";
     if ($parentTag && $this->type == "else") {
         if ($parentTag instanceof H\Tag) {
             $elseTag = $parentTag->tags[count($parentTag->tags) - 1];
             if ($elseTag instanceof H\Tag\Control && in_array($elseTag->type, array('with', 'if'))) {
                 $elseTag->else = true;
             } else {
                 throw new ParseError("You can only use else with |with and |if, you tried |{$parentTag->type}");
             }
         } else {
             throw new ParseError("Unable to use else here");
         }
     }
 }
示例#5
0
文件: Html.php 项目: cseufert/hamle
 function __construct($tag, $class = array(), $attr = array(), $id = "")
 {
     parent::__construct();
     $this->opt = $attr;
     if (isset($attr['class']) && !is_array($attr['class'])) {
         $this->opt['class'] = $attr['class'] ? explode(" ", $attr['class']) : array();
     }
     $this->source = array();
     $this->type = $tag ? $tag : "div";
     if ($class) {
         if (isset($this->opt['class'])) {
             $this->opt['class'] = array_merge($this->opt['class'], $class);
         } else {
             $this->opt['class'] = $class;
         }
     }
     if ($id) {
         $this->opt['id'] = $id;
     }
 }
示例#6
0
文件: Text.php 项目: cseufert/hamle
 function __construct($tag)
 {
     parent::__construct();
     $this->escape = $tag == "_";
 }