Beispiel #1
0
 public function render($name, array $parameters = array())
 {
     ++$this->level;
     // escape only once
     if (1 === $this->level && !isset($parameters['_data'])) {
         $parameters = $this->escapeParameters($parameters);
     }
     $content = parent::render($name, $parameters);
     --$this->level;
     return $content;
 }
Beispiel #2
0
 public function render($name, array $parameters = array())
 {
     ++$this->level;
     list(, $options) = $this->splitTemplateName($name);
     if ('php' === $options['renderer']) {
         // escape only once
         if (1 === $this->level && !isset($parameters['_data'])) {
             $parameters = $this->escapeParameters($parameters);
         }
     }
     $content = parent::render($name, $parameters);
     --$this->level;
     return $content;
 }
Beispiel #3
0
use Symfony\Components\Templating\Engine;
use Symfony\Components\Templating\Renderer\Renderer;
use Symfony\Components\Templating\Storage\Storage;
use Symfony\Components\Templating\Loader\FilesystemLoader;

$t = new LimeTest(1);

class ProjectTemplateRenderer extends Renderer
{
  public function getEngine()
  {
    return $this->engine;
  }

  public function evaluate(Storage $template, array $parameters = array())
  {
  }
}

$loader = new FilesystemLoader(array(__DIR__.'/fixtures/templates/%name%.%renderer%'));
$engine = new Engine($loader);
$engine->set('foo', 'bar');
$engine->getHelperSet()->set(new SimpleHelper('foo'), 'bar');

// ->setEngine()
$t->diag('->setEngine()');
$renderer = new ProjectTemplateRenderer();
$renderer->setEngine($engine);
$t->ok($renderer->getEngine() === $engine, '->setEngine() sets the engine instance tied to this renderer');