cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

volt extend not work

Open subdigger opened this issue 12 years ago • 4 comments

Taking problem with usibg extends in template

application/views/index/index.volt first(actrually only one) line is:

{% extends common/index.volt %}

receive this:

Fatal error: Uncaught exception 'Phalcon\Mvc\View\Exception' with message 'Extends statement must be placed at the first line in the template in ../application/views/index/index.volt on line 1' in ....\public_html\index.php on line 169

....\public_html\index.php line 169 is:

echo $application->handle()->getContent();

In demos http://docs.phalconphp.com/ru/latest/reference/volt.html#id33 just used including

So just cant understend if phalcon support extends or not


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

subdigger avatar Aug 19 '14 18:08 subdigger

Could you please attach the templates files that are causing trouble to allow us to reproduce the issue?

ghost avatar Aug 19 '14 18:08 ghost

Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. so putting plain here

common/index.volt:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    {{ get_title() }}
    {{ stylesheet_link('bootstrap/css/bootstrap.min.css') }}
    {{ stylesheet_link('bootstrap/css/bootstrap-theme.min.css') }}
    {{ stylesheet_link('bootstrap/css/bootstrap-responsive.min.css') }}
    {#{{ stylesheet_link('bootstrap/css/bootstrap-datepicker3.css') }}#}
    {{ stylesheet_link('bootstrap/css/bootstrap-datetimepicker.min.css') }}

    {% if is_main is defined %}
        {{ stylesheet_link('css/style.css') }}
    {% else %}
        {{ stylesheet_link('css/map.css') }}
    {% endif %}
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Your invoices">
    <meta name="author" content="Phalcon Team">
    {% block main_style %}{% endblock %}
</head>
<body id="page1">
{{ javascript_include('js/jquery.min.js') }}
{{ javascript_include('bootstrap/js/bootstrap.min.js') }}
{{ javascript_include('bootstrap/js/bootbox.min.js') }}
{{ javascript_include('js/moment.min.js') }}
{#{{ javascript_include('bootstrap/js/bootstrap-datepicker.js') }}#}
{#{{ javascript_include('bootstrap/js/locales/bootstrap-datepicker.ru.js') }}#}
{{ javascript_include('bootstrap/js/bootstrap-datetimepicker.min.js') }}
{{ javascript_include('bootstrap/js/datetimepicker_locales/bootstrap-datetimepicker.ru.js') }}
{{ javascript_include('js/utils.js') }}
{#{{ content() }}#}
{% block content %}{% endblock %}
<hr>
{% block main_footer %}
    <footer>
        <p>&copy; Company 2014</p>
    </footer>
{% endblock %}
</body>
</html>

index/index.volt, for example just

{% extends common/index.volt %}
or
{#{% extends "common\index.volt" %}#}

subdigger avatar Aug 19 '14 18:08 subdigger

additionaly, initialization in index.php

    $di->set('view', function() use ($config) {

        $view = new \Phalcon\Mvc\View();

        $view->setViewsDir($config->application->viewsDir);

        $view->registerEngines(array(
            ".volt" => 'volt'
        ));

        return $view;
    });

    /**
     * Setting up volt
     */
    $di->set('volt', function($view, $di) {

        $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);

        $volt->setOptions(array(
            'compiledPath' => '../cache/volt/',
            // TODO DEBUG
            'stat' => true,
            'compileAlways' => true
        ));

        return $volt;
    }, true);

Phalcon Version 1.3.2 phalcon_x86_VC9_php5.4.0_1.3.2

subdigger avatar Aug 19 '14 18:08 subdigger

for some reason there was 2 invisible bytes in file. When removed - works fine but i think i should be fixed

extends

subdigger avatar Aug 22 '14 11:08 subdigger