简体   繁体   中英

phalcon volt template engine remove php code blocks

How can i remove php code blocks from volt template file, which has .phtml extension?

forexample:

<!-- must to be remove -->
<h1><?=$tutorial?><h1>
<!-- //remove area -->

<!-- must to be stay  -->
<h1> {{tutorial}} </h1>
<!-- //must to be stay  -->

Note: i use phalcon's last version.

If the extension is .phtml you are using the PHP template engine.

You will have to change your DI view config to include the Volt engine. Volt and PHP engines can be used side by side and will workout which to use based on the extension.

https://docs.phalconphp.com/en/latest/reference/volt.html

<?php

use Phalcon\Mvc\View;

// Registering Volt as template engine
$di->set(
    'view',
    function () {

        $view = new View();

        $view->setViewsDir('../app/views/');

        $view->registerEngines(
            array(
                ".phtml" => 'Phalcon\Mvc\View\Engine\Php',
                ".volt" => 'Phalcon\Mvc\View\Engine\Volt'
            )
        );

        return $view;
    }
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM