public function testRenderInsidePhp() { $i = new Interpolation("#{ImTheWholeThing()}", true); $actual = $i->render(); $this->assertEquals('ImTheWholeThing()', $actual); $i = new Interpolation("\"Hey, look! #{ImInsidePhp()}! And #{\$me + \$too}!\"", true); $actual = $i->render(); $this->assertEquals('"Hey, look! ".(ImInsidePhp())."! And ".($me + $too)."!"', $actual); }
public function render() { $output = $this->_spaces . $this->_haml . "\n"; $interpolation = new Interpolation($output); $output = $interpolation->render(); if ($this->hasChildren()) { $output = $output . $this->renderChildren(); } return $output; }
public function render() { if (null === $this->_filterContainer) { return ''; } $identifier = str_replace(':', '', $this->getHaml()); $filter = $this->_filterContainer->getFilter($identifier); if (null === $filter) { throw new Exception(sprintf("Unknown filter '%s'.", $identifier)); } $interpolation = new Interpolation($filter->filter($this)); return $interpolation->render(); }
public function render() { $output = ""; switch ($this->_commentType) { case CommentNode::HTML_COMMENT_TYPE: $output = $this->renderHtmlComment() . "\n"; break; case CommentNode::HAML_COMMENT_TYPE: $output = $this->renderHamlComment() . "\n"; break; case CommentNode::CONDITIONAL_COMMENT_TYPE: $output = $this->renderConditionalComment() . "\n"; break; default: throw new Exception("Invalid comment type: " . $this->getHaml()); } $interpolation = new Interpolation($output); return $interpolation->render(); }
public function url($data = null, $field = false, $options = array()) { $options += array('style' => 'original', 'urlize' => true); list($model, $field) = explode('.', $field); if (is_array($data)) { if (isset($data[$model])) { if (isset($data[$model]['id'])) { $id = $data[$model]['id']; $filename = $data[$model][$field]; } } elseif (isset($data['id'])) { $id = $data['id']; $filename = $data[$field]; } } if (isset($id) && isset($filename)) { $paths = UploadBehavior::getPaths($model, $id, $field, $filename, $options['style'], array('webroot' => '')); $url = isset($paths['url']) ? $paths['url'] : $paths['path']; } else { $settings = Interpolation::run($model, null, $field, null, $options['style'], array('webroot' => '')); $url = isset($settings['default_url']) ? $settings['default_url'] : null; } return $options['urlize'] ? $this->Html->url($url) : $url; }
public function render() { $interpolation = new Interpolation($this->renderDoctype()); return $interpolation->render(); }
public function testNotAFunctionException() { // Two arrays share the same first number (x-component) $this->setExpectedException('MathPHP\\Exception\\BadDataException'); Interpolation::validate([[0, 0], [0, 5], [1, 1]]); }
private function _interpolate($str) { if (!$this->_containsInterpolation($str)) { return $str; } $nStr = ''; $s = new StringScanner($str); $quote = $s->check(StringScanner::rQUOTE); // If it doesn't starts with a quote, it CAN'T be inside php context if (empty($quote) || !s($str)->endsWith($quote)) { $int = new Interpolation($str); return $int->render(); } $int = new Interpolation($str, true); return $int->render(); }
protected function interpolate(Model $Model, $field, $filename, $style) { $settings = $this->settings[$Model->alias][$field]; $keys = array('path', 'url', 'default_url'); foreach ($keys as $key) { if (isset($settings[$key])) { $settings[$key] = Interpolation::run($settings[$key], $Model->alias, $Model->id, $field, $filename, $style); } } return $settings; }
private function renderTagContent($content) { if ($this->hasChildren()) { $content = "\n" . $this->renderChildren() . $this->getSpaces(); } if ($content === null) { $content = ''; } if ($this->_phpVariable) { $content = "<?php echo " . $content . " ?>"; } else { $interpolation = new Interpolation($content); $content = $interpolation->render(); } return $content; }