/**
  * @covers Piccolo\Templating\Engine\Twig\TwigTemplateEngine::renderFile
  */
 public function testRender()
 {
     //setup
     $engine = new TwigTemplateEngine(false);
     //act
     $content = $engine->renderFile(__DIR__ . '/../testdata', __DIR__ . '/../testdata/index.twig', ['test' => 'Hello world!']);
     //assert
     $this->assertEquals('Hello world!', $content);
 }
Exemplo n.º 2
0
 public static function initialize($templateRootPath, $cacheStoragePath)
 {
     Twig_Autoloader::register();
     $debugModeOptionValue = COption::GetOptionString("htc.twigintegrationmodule", "debug_mode");
     $debugMode = $debugModeOptionValue == "Y" ? true : false;
     $loader = new Twig_Loader_Filesystem($templateRootPath);
     self::$twigEnvironment = new Twig_Environment($loader, array('autoescape' => false, 'cache' => $cacheStoragePath, 'debug' => $debugMode));
     self::addExtensions();
     global $arCustomTemplateEngines;
     $arCustomTemplateEngines["twig"] = array("templateExt" => array("twig"), "function" => "renderTwigTemplate");
 }
Exemplo n.º 3
0
<?php

//путь вычисляется относительно папки с модулем htc.twigintegrationmodule
CModule::AddAutoloadClasses('htc.twigintegrationmodule', array('TwigTemplateEngine' => 'classes/general/templating/TwigTemplateEngine.php', 'BitrixTwigExtension' => 'classes/general/templating/BitrixTwigExtension.php', 'Twig_Autoloader' => 'vendor/Twig/Autoloader.php'));
// Initialize Twig template engine
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
$cacheStoragePathOption = COption::GetOptionString("htc.twigintegrationmodule", "cache_storage_path");
if ($cacheStoragePathOption == "") {
    $cacheStoragePath = $documentRoot . BX_PERSONAL_ROOT . "/cache/twig";
} else {
    $cacheStoragePath = $documentRoot . $cacheStoragePathOption;
}
TwigTemplateEngine::initialize($documentRoot, $cacheStoragePath);
Exemplo n.º 4
0
    echo bitrix_sessid_post();
    $tabControl->End();
    ?>
    </form>

    <?php 
    if (!empty($notes)) {
        echo BeginNote();
        foreach ($notes as $key => $str) {
            echo '<span class="required"><sup>' . ($key + 1) . '</sup></span>' . $str . '<br>';
        }
        echo EndNote();
    }
}
?>

<?php 
//очистка кеша шаблонов
if ($_POST["clear_twig_cache"] === "y") {
    TwigTemplateEngine::clearCacheFiles();
}
?>

<script type="text/javascript">
    $(document).ready(function(){
        $("#clear-twig-cache").click(function(){
            $("input[name='clear_twig_cache']").val("y");
            $("form[name='twigintegrationmodule_opt_form']").submit();
        });
    });
</script>