kfreiman/yii2-lightncandy

The LightnCandy integration for the Yii2 framework.

Installs: 77

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2015-04-07 18:25 UTC

This package is not auto-updated.

Last update: 2024-11-13 10:06:11 UTC


README

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.