Migrate from 8.x-1.x to 8.x-2.x

Last updated on
17 January 2019

The new version of Bamboo Twig 8.x-2.x bring a lot of new features, boost the performances by using lazy loading, improve the code quality with automated workflow and include automated unit and kernel tests to ensure stability.

The new version 8.x-2.x is a major release of Bamboo Twig and deal with a lot of restructuration and complete refactoring from the old version 8.x-1.x.

The following guide will help you to migrate from the version 8.x-1.x to the version 8.x-2.x.

Dates

Function/Filter 8.x-1.x 8.x-2.x Module
Format date using Drupal i118n
{{ node.changed.value|date_format('d M, h:i A') }}
{{ node.changed.value|bamboo_i18n_format_date('custom', 'd M, h:i A') }}
Bamboo Twig - Internationalization

Files

Function/Filter 8.x-1.x 8.x-2.x Module
Retrieve file Url into theme
{{ theme_url('bartik', 'images/required.svg') }}
{{ file_url(bamboo_path_system('theme', 'bartik') ~'/images/required.svg') }}
{{ bamboo_file_url_absolute(bamboo_path_system('theme', 'bartik') ~'/images/required.svg') }}
Bamboo Twig - Path
Retrieve the Extension file from given mimeType
{{ file.entity.mimeType|extension_guesser }}
{{ file.entity.mimeType|bamboo_file_extension_guesser  }}
Bamboo Twig - File

Loaders

Function/Filter 8.x-1.x 8.x-2.x Module
Render a Block
{{ load_block('bartik_powered') }}
{{ bamboo_render_block('bartik_powered') }}
Bamboo Twig - Loader
Render an Entity
{{ load_entity('node', node.nid.value) }}
{{ bamboo_render_entity('node', node.nid.value, 'teaser') }}
Bamboo Twig - Loader
Render a Form
{{ load_form('system', 'CronForm') }}
{{ bamboo_render_form('system', 'CronForm') }}
Bamboo Twig - Loader

Image Styles

Function/Filter 8.x-1.x 8.x-2.x Module

Image Style from File ID

Image Style from Field

{% set images = image_style_field(node.field_image, {'thumb': 'thumbnail', 'lg': 'large'}) %}
{{ images.thumb }}
{{ images.lg }}
{{ bamboo_render_image(node.field_image.entity.fid.value, 'thumbnail') }}
{{ bamboo_render_image_style(node.field_image.entity.uri.value, 'thumbnail') }}
Bamboo Twig - Loader

Configurations

Function/Filter 8.x-1.x 8.x-2.x Module

Configuration from Config API

{% set settings = load_config('system.site', 'mail') %}
{{ bamboo_config_get('system.site', 'mail') }}
Bamboo Twig - Config
Configuration from State API
{% set settings = load_state('system.cron_last') %}
{{ bamboo_state_get('system.cron_last') }}
Bamboo Twig - Config

Help improve this page

Page status: No known problems

You can: