The Volt engine doesn't work in Phalcon.

Source: Internet
Author: User

Build the project multi-module project, the Volt engine does not work, JS,CSS load does not respond, partials is not good, the view can not output, it seems that the Volt engine is not registered success or other reasons?

PS: But it comes with the engine. Files with the suffix. phtml format can be introduced in the manual js,css,partials file. On the basis of the above, after the suffix into the. volt format, what else needs to be changed to make it so?

Directory structure

The following is some of the code in config/services.php, which is automatically generated when the project is built.

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

The module.php under the module is still generated when the project is produced, no change!

In the Views/index.volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load JS

{{ javascript_include("/js/1.11.3.jquery.min.js") }}

Reply content:

Build the project multi-module project, the Volt engine does not work, JS,CSS load does not respond, partials is not good, the view can not output, it seems that the Volt engine is not registered success or other reasons?

PS: But it comes with the engine. Files with the suffix. phtml format can be introduced in the manual js,css,partials file. On the basis of the above, after the suffix into the. volt format, what else needs to be changed to make it so?

Directory structure

The following is some of the code in config/services.php, which is automatically generated when the project is built.

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

The module.php under the module is still generated when the project is produced, no change!

In the Views/index.volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load JS

{{ javascript_include("/js/1.11.3.jquery.min.js") }}

Paste the code portion of your volt template registered in Di
Paste your loading JS, CSS part of the code
Paste the part of your code that uses partial
Sticker Code! Sticker Code! Sticker Code! Re-say three! No code to mention code-related issues, are bullying

$di->set (' View ', function () use ($config) {$view = new view ();    $view->setviewsdir (app_path. $config->application->layouts_dir); $view->registerengines (Array ('. Volt ' = function ($view, $di) use ($config) {$v                Olt = new Voltextension ($view, $di); $volt->setoptions (Array (' compiledpath ' = App_path. $config->ap                        Plication->cache_dir, ' compilealways ' = $config->application->debug, ' Compiledseparator ' = ' _ ', ' Layoutdir ' and $config->application->layo                Uts_dir,)); if (!empty ($config->volt->extensions)) {foreach ($config->volt->extensions as $extension _c                    Lass_name) {$di->get (' volt.extension ')->register ($volt, New $extension _class_name ($di)); }                } return $volt;    }, '. phtml ' = ' phalcon\mvc\view\engine\php ' ...); return $view;}, True);

Directory structure

The following is a partial code in config/services.php, which is generated automatically in the build project

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

The module.php under the module is still generated when the project is produced, no change!

In the Views/index.volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load JS

{{ javascript_include("/js/1.11.3.jquery.min.js") }}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.