[英]Have problems with using Volt with phalcon
繼承的接縫在伏特模板中不起作用。
Phalcon版本是0.6.1
有一個文件結構:
index.php文件:
<?php
$di = new Phalcon\DI\FactoryDefault();
$di->set('volt', function ($view, $di){
return new Phalcon\Mvc\View\Engine\Volt($view, $di);
});
$view = new \Phalcon\Mvc\View();
$view->setViewsDir("views/");
$view->registerEngines(array(
".html" => 'volt'
));
$view->setDi($di);
$view->start();
$view->render("index", 'index');
$view->finish();
echo $view->getContent();
視圖/索引/ index.html中
{% extends "layouts/main.html" %}
{% block content %}
<h2>Index</h2>
{% endblock %}
視圖/布局/ main.html中
<h1>Main</h1>
{% block content %}
Not index
{% endblock %}
當我運行php index.php
我得到:
未捕獲的異常'Phalcon \\ Mvc \\ View \\ Exception',消息'模板視圖擴展'layouts / main.html'不存在'
這是因為應用程序無法在實際路徑中找到文件main.html
。 如果添加它的完整路徑,但這樣做很不方便。
這樣的東西會起作用
{% extends "../views/layouts/main.html" %}
或者如果您的應用程序在app
{% extends "../app/views/layouts/main.html" %}
我相信應該有一種方法可以直接從Volt的設置中引用根路徑和/或視圖路徑。 這很可能是一個NFR。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.