Bamboo Twig


This project is not covered by Drupal’s security advisory policy.

Bamboo Twig. Drupal 8 powered module.

Bamboo Twig module provides some Twig extensions with some useful functions and filters that can improve development experience.

You need Bamboo Twig if

  • You need to "Format date using Drupal I118n" from your twig.
  • You need to "Load a Block" from your twig.
  • You need to "Load an Entity with view mode" from your twig.
  • You need to "Load a Form" from your twig.
  • You need to "Load a ImageStyle" from your twig.
  • You need to "Retrieve the Extension file from given mimeType" from your twig.

Bamboo Twig can do a lot more than that, but those are some of the obvious uses of Bamboo Twig.

Performances

For performances reasons, Bamboo Twig has been splitted in multiple sub-modules for each topics he provides Twigs.

Bamboo Twig versions

Bamboo Twig is only available for Drupal 8 !

The module is ready to be used in Drupal 8, there are no known issues.

Dependencies

The Drupal 8 version of Bamboo Twig requires Disrupt Tools if you use Bamboo Twig - Images.

Similar modules

For now (2017-03-21) Twig Tweak is a far better option than Bamboo Twig.

Roadmap

8.1.x

  • UnitTests
  • Twig Extensions (Dates, Texts, Array)
  • Loader for Views
  • Loader for Regions
  • Loader for Field
  • Loader for Menu
  • Usage of Token

8.2.x

  • Improvments on ImageStyle between pregenerated derivated or on-the-fly generation

Supporting organizations

This project is sponsored by Antistatique. We are a Swiss Web Agency, Visit us at www.antistatique.net or Contact us.

Examples

Dates

{# Format date using Drupal i118n. #}
<dt>Format date:</dt>
<dd>{{ node.changed.value|date_format('d M, h:i A') }}</dd>

Files

{# Retrieve file Url into theme. #}
<dt>Files:</dt>
<dd>{{ theme_url('bartik', 'images/required.svg') }}</dd>

{# Retrieve the Extension file from given mimeType. #}
<dt>Extension file:</dt>
<dd>{{ file.entity.mimeType|extension_guesser() }}</dd>

Loaders

{# Load a Block. #}
<dt>Block:</dt>
<dd>{{ load_block('bartik_powered') }}</dd>

{# Load an Entity. #}
<dt>Entity:</dt>
<dd>{{ load_entity('node', node.nid.value) }}</dd>

{# Load an Entity with view mode. #}
<dt>Entity:</dt>
<dd>{{ load_entity('node', node.nid.value, 'teaser') }}</dd>

{# Load a Form. #}
<dt>Form:</dt>
<dd>{{ load_form('contact', 'ContactForm') }}</dd>

Image Styles

{# Image Style from File ID. #}
<dt>Image Styles:</dt>
<dd>{% set images = image_style_field(node.field_image, {'thumb': 'thumbnail', 'lg': 'large'}) %}</dd>

{# Image Style from Field. #}
<dt>Image Styles:</dt>
<dd>{% set images = image_style_file(node.field_image.entity.fid.value, {'thumb': 'thumbnail', 'lg': 'large'}) %}</dd>

Configurations

{# Configuration from Config API. #}
<dt>Config API:</dt>
<dd>{% set settings = load_config('system.site') %}</dd>

{# Configuration from State API. #}
<dt>State API:</dt>
<dd>{% set settings = load_state('system.cron_last') %}</dd>
Supporting organizations: 

Bamboo Twig项目的Drush安装命令:复制到剪贴板

注:个别模块仍需开启相关子模块。
周安装量: 
1
维护状态: 
最低限度维护
开发状态: 
积极开发中

其他版本下载:

版本下载地址发布日期发布说明翻译下载
8.x-1.0tar.gz (12.73 KB) | zip (23.34 KB)2017年3月19日发布说明简 | 繁 | 更多

开发版本下载:

版本下载地址发布日期发布说明翻译下载
8.x-2.x-devtar.gz (42.95 KB) | zip (73.99 KB)2017年4月24日发布说明简 | 繁 | 更多
8.x-1.x-devtar.gz (19.44 KB) | zip (38.08 KB)2017年3月30日发布说明简 | 繁 | 更多