Skip to content

vintagesucks/twig-renderer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twig view renderer

Build Status Dependabot Packagist Packagist

This extension allows you to use Twig 3.x templates in Yii 1

Requirements

  • Yii 1.1 or above
  • PHP 7.2 or above

Installing

  • Install via Composer:
composer require vintagesucks/twig-renderer
  • Add the following to your config file 'components' section:
'viewRenderer' => [
    'class' => 'root.vendor.vintagesucks.twig-renderer.ETwigViewRenderer',
    'twigPathAlias' => 'root.vendor.twig.twig.lib.Twig',
    'fileExtension' => '.twig',
],

Usage

  • See Twig syntax
  • Current controller properties are accessible via {{ this.pageTitle }}
  • Yii::app() object is accessible via {{ App }} (Example: {{ App.name }})
  • Yii's core static classes (CHtml, for example) are accessible via {{ C.ClassNameWithoutFirstC.Method }} (Example: {{ C.Html.textField(name,'value') }})
  • To call functions or methods which return non-string results wrap these calls in a void function: {{ void(App.clientScript.registerScriptFile(...)) }}

Development

Run test matrix locally with act:

act --job build \
  --workflows .github/workflows/build.yml \
  --platform ubuntu-latest=shivammathur/node:latest \
  --container-architecture linux/amd64

About

Twig 3.x for Yii 1.1

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.6%
  • Twig 0.4%