pug-php/pug-phalcon

Phalcon 的类似 HAML 模板引擎

1.2.0 2019-12-02 06:55 UTC

This package is auto-updated.

Last update: 2024-09-22 09:03:11 UTC


README

Phalcon 的 Pug 模板引擎

要在您的 Phalcon 应用程序中使用 Pug,只需在 composer.json 的 require 部分添加以下内容:

"pug-php/pug-phalcon": "^1.0"

或者使用命令行

composer require pug-php/pug-phalcon

然后注册模板

require '../vendor/autoload.php';

// ...
$di = new FactoryDefault();

// Setting up the view component
$di['view'] = function() {
    $view = new View();
    $view->setViewsDir('../app/views/');
    $view->registerEngines(array(
        ".pug" => function($view, $di) {
            return new \Phalcon\Mvc\View\Engine\Pug($view, $di, array(
                'cache' => '/tmp/myproject/pug',
                'prettyprint' => APP_ENV == 'development',
            ));
        }
    ));

    return $view;
};

现在您可以在视图目录中添加 pug 文件

app/views/index.pug

doctype html
html
  head
    title pug-phalcon
  body
    p Generetad with pug-phalcon