PHP Класс yii\twig\ViewRenderer

С версии: 2.0
Автор: Alexander Makarov ([email protected])
Наследование: extends yii\base\ViewRenderer
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$cachePath the directory or path alias pointing to where Twig cache will be stored. Set to false to disable templates cache.
$extensions Custom extensions. Example: ['Twig_Extension_Sandbox', new \Twig_Extension_Text()]
$filters Custom filters. Keys of the array are names to call in template, values are names of functions or static methods of some class. Example: ['rot13' => 'str_rot13', 'jsonEncode' => '\yii\helpers\Json::encode']. In the template you can use it like this: {{ 'test'|rot13 }} or {{ model|jsonEncode }}.
$functions Custom functions. Keys of the array are names to call in template, values are names of functions or static methods of some class. Example: ['rot13' => 'str_rot13', 'a' => '\yii\helpers\Html::a']. In the template you can use it like this: {{ rot13('test') }} or {{ a('Login', 'site/login') | raw }}.
$globals Objects or static classes. Keys of the array are names to call in template, values are objects or names of static classes. Example: ['html' => '\yii\helpers\Html']. In the template you can use it like this: {{ html.a('Login', 'site/login') | raw }}.
$lexerOptions Twig lexer options. Example: Smarty-like syntax: php [ 'tag_comment' => ['{*', '*}'], 'tag_block' => ['{', '}'], 'tag_variable' => ['{$', '}'] ]
$options Twig options.
$twig twig environment object that renders twig templates
$twigFallbackPaths twig fallback paths
$twigModulesNamespace twig namespace to use in modules templates
$twigViewsNamespace twig namespace to use in templates
$twigWidgetsNamespace twig namespace to use in widgets templates
$uses namespaces and classes to import. Example: php [ 'yii\bootstrap', 'app\assets', \yii\bootstrap\NavBar::className(), ]

Открытые методы

Метод Описание
addExtensions ( array $extensions ) Adds custom extensions
addFilters ( array $filters ) Adds custom filters
addFunctions ( array $functions ) Adds custom functions
addGlobals ( array $globals ) Adds global objects or static classes
init ( )
render ( View $view, string $file, array $params ) : string Renders a view file.
setLexerOptions ( array $options ) Sets Twig lexer options to change templates syntax

Защищенные методы

Метод Описание
addAliases ( Twig_Loader_Filesystem $loader, array $aliases ) Adds aliases
addFallbackPaths ( Twig_Loader_Filesystem $loader, Theme | null $theme ) Adds fallback paths to twig loader

Приватные методы

Метод Описание
_addCustom ( string $classType, array $elements ) Adds custom function or filter

Описание методов

addAliases() защищенный Метод

Adds aliases
protected addAliases ( Twig_Loader_Filesystem $loader, array $aliases )
$loader Twig_Loader_Filesystem
$aliases array

addExtensions() публичный Метод

Adds custom extensions
public addExtensions ( array $extensions )
$extensions array @see self::$extensions

addFallbackPaths() защищенный Метод

Adds fallback paths to twig loader
С версии: 2.0.5
protected addFallbackPaths ( Twig_Loader_Filesystem $loader, Theme | null $theme )
$loader Twig_Loader_Filesystem
$theme yii\base\Theme | null

addFilters() публичный Метод

Adds custom filters
public addFilters ( array $filters )
$filters array @see self::$filters

addFunctions() публичный Метод

Adds custom functions
public addFunctions ( array $functions )
$functions array @see self::$functions

addGlobals() публичный Метод

Adds global objects or static classes
public addGlobals ( array $globals )
$globals array @see self::$globals

init() публичный Метод

public init ( )

render() публичный Метод

This method is invoked by [[View]] whenever it tries to render a view. Child classes must implement this method to render the given view file.
public render ( View $view, string $file, array $params ) : string
$view yii\base\View the view object used for rendering the file.
$file string the view file.
$params array the parameters to be passed to the view file.
Результат string the rendering result

setLexerOptions() публичный Метод

Sets Twig lexer options to change templates syntax
public setLexerOptions ( array $options )
$options array @see self::$lexerOptions

Описание свойств

$cachePath публичное свойство

the directory or path alias pointing to where Twig cache will be stored. Set to false to disable templates cache.
public $cachePath

$extensions публичное свойство

Custom extensions. Example: ['Twig_Extension_Sandbox', new \Twig_Extension_Text()]
public $extensions

$filters публичное свойство

Custom filters. Keys of the array are names to call in template, values are names of functions or static methods of some class. Example: ['rot13' => 'str_rot13', 'jsonEncode' => '\yii\helpers\Json::encode']. In the template you can use it like this: {{ 'test'|rot13 }} or {{ model|jsonEncode }}.
public $filters

$functions публичное свойство

Custom functions. Keys of the array are names to call in template, values are names of functions or static methods of some class. Example: ['rot13' => 'str_rot13', 'a' => '\yii\helpers\Html::a']. In the template you can use it like this: {{ rot13('test') }} or {{ a('Login', 'site/login') | raw }}.
public $functions

$globals публичное свойство

Objects or static classes. Keys of the array are names to call in template, values are objects or names of static classes. Example: ['html' => '\yii\helpers\Html']. In the template you can use it like this: {{ html.a('Login', 'site/login') | raw }}.
public $globals

$lexerOptions публичное свойство

Twig lexer options. Example: Smarty-like syntax: php [ 'tag_comment' => ['{*', '*}'], 'tag_block' => ['{', '}'], 'tag_variable' => ['{$', '}'] ]
См. также: http://twig.sensiolabs.org/doc/recipes.html#customizing-the-syntax
public $lexerOptions

$options публичное свойство

Twig options.
См. также: http://twig.sensiolabs.org/doc/api.html#environment-options
public $options

$twig публичное свойство

twig environment object that renders twig templates
public $twig

$twigFallbackPaths публичное свойство

twig fallback paths
С версии: 2.0.5
public $twigFallbackPaths

$twigModulesNamespace публичное свойство

twig namespace to use in modules templates
С версии: 2.0.5
public $twigModulesNamespace

$twigViewsNamespace публичное свойство

twig namespace to use in templates
С версии: 2.0.5
public $twigViewsNamespace

$twigWidgetsNamespace публичное свойство

twig namespace to use in widgets templates
С версии: 2.0.5
public $twigWidgetsNamespace

$uses публичное свойство

namespaces and classes to import. Example: php [ 'yii\bootstrap', 'app\assets', \yii\bootstrap\NavBar::className(), ]
public $uses