locaine/lcn-template-block-bundle
最新稳定版本:1.0.1
Composer 安装命令:
composer require locaine/lcn-template-block-bundle
包简介
Populate blocks of template code from PHP/Twig and output them later in a Twig Template
关键字:
README 文档
README
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require locaine/lcn-template-block-bundle "~1.0"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Lcn\TemplateBlockBundle\LcnTemplateBlockBundle(), ); // ... } // ... }
Usage
PHP
Example controller code:
//add code to a block $this->container->get('lcn.template_block')->add('BLOCK_NAME', 'BLOCK_CONTENT'); ////adding the same code to a block again is ignored by default. You can force adding the same code by supplying false as third argument $this->container->get('lcn.template_block')->add('BLOCK_NAME', 'BLOCK_CONTENT', false); //you can set the code in a block effectively overriding existing code in the block $this->container->get('lcn.template_block')->set('BLOCK_NAME', 'BLOCK_CONTENT'); //clear a block $this->container->get('lcn.template_block')->clear('BLOCK_NAME'); //get the code of a block $this->container->get('lcn.template_block')->get('BLOCK_NAME', 'OPTIONAL_FALLBACK_CODE');
TWIG
Example Twig template code:
{# add code to a block #}
{{ lcn_add_to_template_block('BLOCK_NAME', 'BLOCK_CONTENT') }}
{# adding the same code to a block again is ignored by default. You can force adding the same code by supplying false as third argument #}
{{ lcn_add_to_template_block('BLOCK_NAME', 'BLOCK_CONTENT', false) }}
{# you can set the code in a block effectively overriding existing code in the block #}
{{ lcn_set_template_block('BLOCK_NAME', 'BLOCK_CONTENT') }}
{# clear a block #}
{{ lcn_clear_template_block('BLOCK_NAME') }}
{# get the code of a block #}
{{ lcn_template_block('BLOCK_NAME', 'OPTIONAL_FALLBACK_CODE') }}
{# the code is escaped by default, but cou can also get the raw code of a block #}
{{ lcn_template_block_raw('BLOCK_NAME', 'OPTIONAL_FALLBACK_CODE') }}
统计信息
- 总下载量: 254
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-09