Esempio n. 1
0
 /**
  * Renders the parsed tree.
  */
 public function render()
 {
     $filter = $this->filter;
     $filtered = $filter::filter($this);
     if (is_array($filtered)) {
         $filtered = implode('#{"\\n"}' . $this->indent(), $filtered);
     }
     return '<?php echo (' . ruby\InterpolatedString::compile($filtered) . '); ?>';
 }
Esempio n. 2
0
 /**
  * Renders the content of the node.
  */
 public function render()
 {
     $this->content = (string) $this->content;
     if ($this->escape) {
         $this->content = htmlentities($this->content);
     }
     if ($this->preserve) {
         $this->preserve();
     }
     $this->content = '<?php echo (' . ruby\InterpolatedString::compile($this->content) . '); ?>';
     return $this->content;
 }
Esempio n. 3
0
 /**
  * Renders the content of the node.
  */
 public function render()
 {
     $newline = '<?php echo "\\n"; ?>';
     $return = '<!--';
     if ($this->conditional) {
         return $return . $this->content . '>' . $newline . $this->render_children() . $newline . $this->indent() . '<![endif]-->';
     } else {
         if (empty($this->children)) {
             $this->content = ruby\InterpolatedString::compile($this->content);
             return $return . ' <?php echo (' . $this->content . '); ?> -->';
         } else {
             return $return . $newline . $this->render_children() . $newline . $this->indent() . '-->';
         }
     }
 }
Esempio n. 4
0
 /**
  * Parses HTML attributes from the content.
  */
 protected static function parse_html_attributes(nodes\Tag $node)
 {
     if ($node->content[0] == '(') {
         $html_attributes = static::extract_balanced($node, '(', ')');
         if ($html_attributes === false) {
             static::$multiline = self::MULTILINE_HTML_ATTRIBUTES;
             return;
         }
         $attributes = array();
         foreach (static::quote_safe_explode(' ', $html_attributes) as $entry) {
             $parts = static::quote_safe_explode('=', $entry);
             if (count($parts) != 2) {
                 $node->exception('Parse error: bad html attribute syntax');
             }
             if ($parts[1][0] == '"') {
                 $parts[1] = ruby\InterpolatedString::compile($parts[1]);
             }
             $attributes[$parts[0]] = $parts[1];
         }
         foreach ($attributes as $attribute => $value) {
             $node->attributes[] = array('\'' . $attribute . '\'', $value);
         }
         $node->content = substr($node->content, strlen($html_attributes) + 2);
     }
     static::parse_ruby_attributes($node);
 }
Esempio n. 5
0
 /**
  * Handles a value.  Assumes $value is trimmed.
  */
 protected function handle_value($value)
 {
     switch ($value[0]) {
         case '[':
             $value = new ruby\RArray($value, $this->node);
             $value = $value->to_a();
             break;
         case '{':
             $value = new ruby\Hash($value, $this->node);
             $value = $value->to_a();
             break;
         case '"':
             $value = ruby\InterpolatedString::compile($value);
             break;
         case ':':
             $value = var_export(substr($value, 1), true);
             break;
     }
     return $value;
 }