/** * */ public function testCompile() { $template = Template::compile(':foo {:bar}', ['foo' => 'foo', 'bar' => 'bar']); $this->assertEquals('foo bar', $template); $template = Template::compile(':html', ['html' => '<html>'], 'htmlspecialchars'); $this->assertEquals('<html>', $template); }
/** * {@inheritDoc} */ public function prepare($url) { if (preg_match($this->_pattern, $url, $matches)) { $url = Template::compile($this->_template, ['id' => $matches['id']]); } return $url; }
/** * {@inheritDoc} */ public function present(Media $Media) { $switch = $Media->get($this->_switch); if ($switch && !$Media->has($this->_property)) { foreach ($this->_templates as $pattern => $template) { if (preg_match($pattern, $switch)) { $Media->set($this->_property, Template::compile($template, $Media->properties(), 'htmlspecialchars')); break; } } } return $Media; }
/** * Builds an oEmbed configuration from settings. * * @param string $url URL to embed. * @return Config Configuration. */ protected function _buildConfig($url) { $endpoint = Template::compile($this->get('endpoint'), compact('url'), 'urlencode'); return new Config($endpoint, $this->get('format')); }