Skip to content
Yii2 lightncandy extention/
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
ViewRenderer.php
composer.json

README.md

yii2-lightncandy

Yii2 lightncandy extention/

This extension provides a ViewRender that would allow you to use LightnCandy, an extremely fast PHP implementation of handlebars and mustache.

To use this extension, simply add the following code in your application configuration:

return [
    //....
    'components' => [
        'view' => [
            'renderers' => [
                'handlebars' => [
                    'class' => 'kfreiman\lightncandy\ViewRenderer',
                    // the file extension of Handlebars templates
                    // 'extension' => ['.handlebars', '.mustache']',
                    // path alias pointing to where Handlebars cache will be stored. Set to false to disable templates cache.
                    // 'cache_preffix' => 'LightnCandy_',
                    // 'flags' => LightnCandy::FLAG_INSTANCE |
                    //    LightnCandy::FLAG_NOESCAPE |
                    //    LightnCandy::FLAG_SPVARS |
                    //    LightnCandy::FLAG_RUNTIMEPARTIAL |
                    //    LightnCandy::FLAG_HANDLEBARSJS
                    //
                    //    and at Yii dev enviroment
                    //    LightnCandy::FLAG_ERROR_EXCEPTION |
                    //    LightnCandy::FLAG_RENDER_DEBUG
                    //  additional LightnCandy options
                    // 'options' => []',
                ],
            ],
        ],
    ],
];

Or, you can declarate view component in your code

Yii::$app->set('view', [
    'class' => 'yii\web\View',
    'renderers' => [
        'handlebars' => [
            'class' => 'kfreiman\lightncandy\ViewRenderer',
            'extension' => ['.handlebars','.js','.mustache'],
        ],
    ]
]);

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kfreiman/yii2-lightncandy

or add

"kfreiman/yii2-lightncandy": "*"

to the require section of your composer.json.

You can’t perform that action at this time.