Twig_Environment::setCompiler PHP Method

setCompiler() public method

Sets the Compiler instance.
public setCompiler ( Twig_CompilerInterface $compiler )
$compiler Twig_CompilerInterface A Twig_CompilerInterface instance
    public function setCompiler(Twig_CompilerInterface $compiler)
    {
        $this->compiler = $compiler;
    }

Usage Example

Example #1
0
 /**
  * @dataProvider getGenerationTests
  */
 public function testGenerate($inputFile, $outputFile)
 {
     $env = new \Twig_Environment();
     $env->addExtension(new \Twig_Extension_Core());
     $env->addExtension(new TwigJsExtension());
     $env->setLoader(new \Twig_Loader_Filesystem(__DIR__ . '/Fixture/templates'));
     $env->setCompiler(new JsCompiler($env));
     $source = file_get_contents($inputFile);
     $this->assertEquals(file_get_contents($outputFile), $env->compileSource($source, $inputFile));
 }
All Usage Examples Of Twig_Environment::setCompiler