承接 orbis-labs/pug-symfony 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

orbis-labs/pug-symfony

Composer 安装命令:

composer require orbis-labs/pug-symfony

包简介

Pug template engine for Symfony

README 文档

README

Latest Stable Version Build Status StyleCI Code Climate

Pug template engine for Symfony

Install

In the root directory of your Symfony project, open a terminal and enter:

composer require orbis-labs/pug-symfony

Add in app/config/services.yml:

services:
    templating.engine.pug:
        class: PugBundle\PugTemplateEngine
        arguments: ["@kernel"]

Add jade in the templating.engines setting in app/config/config.yml:

...
    templating:
        engines: ['pug', 'twig', 'php']

Configure

You can set pug options by accessing the container (from controller or from the kernel) in Symfony.

$services = $kernel->getContainer();
$pug = $services->get('templating.engine.pug');
$pug->setOptions(array(
  'pretty' => true,
  'pugjs' => true,
  // ...
));
// You can get the Pug engine to call any method available in pug-php
$pug->getEngine()->share('globalVar', 'foo');
$pug->getEngine()->addKeyword('customKeyword', $bar);

See the options in the pug-php README: https://github.com/pug-php/pug And methods directly available on the service: https://github.com/pug-php/pug-symfony/blob/master/src/Jade/JadeSymfonyEngine.php

Usage

Create jade views by creating files with .pug extension in app/Resources/views such as contact.html.pug with some Jade like this:

h1
  | Hello
  =name

Then call it in your controller:

/**
 * @Route("/contact")
 */
public function contactAction()
{
    return $this->render('contact/contact.html.pug', [
        'name' => 'Bob',
    ]);
}

Deployment

In production, you better have to pre-render all your templates to improve performances. To do that, you have to add Pug\PugSymfonyBundle\PugSymfonyBundle in your registered bundles.

In app/AppKernel.php, in the registerBundles() method, add the Pug bundle:

public function registerBundles()
{
    $bundles = [
        ...
        new PugBundle\PugBundle(),
    ];

This will make the assets:publish command available, now each time you deploy your app, enter the command below: php bin/console assets:publish --env=prod

统计信息

  • 总下载量: 72
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固