oskarstark/env-var-extension

A Twig extension to access env variables

1.1.2 2021-03-19 12:34 UTC

This package is auto-updated.

Last update: 2021-09-28 13:05:34 UTC


README

This library provides methods to use environment variables in Twig templates.

CI

Installation

composer require oskarstark/env-var-extension
# config/services.yaml
services:
    OskarStark\Twig\EnvVarExtension:
        tags: ['twig.extension']

Usage

To access the value of an existing environment variable BRANCH_NAME=develop

{{ env(BRANCH_NAME) }} # prints 'develop'

You can also check if an envirnment variable exists:

{{ has_env(BRANCH_NAME) }} # returns: true