简体   繁体   English

phalcon伏特模板引擎删除PHP代码块

[英]phalcon volt template engine remove php code blocks

How can i remove php code blocks from volt template file, which has .phtml extension? 如何从伏特模板文件中删除php代码块,其中包含.phtml扩展名?

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. 注意:我使用phalcon的最新版本。

If the extension is .phtml you are using the PHP template engine. 如果扩展名是.phtml那么您正在使用PHP模板引擎。

You will have to change your DI view config to include the Volt engine. 您必须更改DI视图配置以包含Volt引擎。 Volt and PHP engines can be used side by side and will workout which to use based on the extension. Volt和PHP引擎可以并排使用,并根据扩展名进行锻炼。

https://docs.phalconphp.com/en/latest/reference/volt.html 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;
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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