Movatterモバイル変換


[0]ホーム

URL:


LightnCandy option: FLAG_ECHO

compile toecho 'a', $b, 'c'; to improve performance. This will slow down rendering when the template and data are simple, but will improve 5% ~ 10% when the data is big and looping in the template.

Sample Codes

compile to'a' . $b . 'c' when do not use FLAG_ECHO

Used option: FLAG_JSTRUE

Data:
NULL
Template:
A{{{foo}}}C
Result:
use \LightnCandy\Runtime as LR;return function ($in = null, $options = null) {    $helpers = array();    $partials = array();    $cx = array(        'flags' => array(            'jstrue' => true,            'jsobj' => false,            'jslen' => false,            'spvar' => false,            'prop' => false,            'method' => false,            'lambda' => false,            'mustlok' => false,            'mustlam' => false,            'mustsec' => false,            'echo' => false,            'partnc' => false,            'knohlp' => false,            'debug' => isset($options['debug']) ? $options['debug'] : 1,        ),        'constants' => array(),        'helpers' => isset($options['helpers']) ? array_merge($helpers, $options['helpers']) : $helpers,        'partials' => isset($options['partials']) ? array_merge($partials, $options['partials']) : $partials,        'scopes' => array(),        'sp_vars' => isset($options['data']) ? array_merge(array('root' => $in), $options['data']) : array('root' => $in),        'blparam' => array(),        'partialid' => 0,        'runtime' => '\LightnCandy\Runtime',    );        $inary=is_array($in);    return 'A'.LR::raw($cx, (($inary && isset($in['foo'])) ? $in['foo'] : null)).'C';};
Source Code
require('./vendor/autoload.php');useLightnCandy\LightnCandy;$template="A{{{foo}}}C";$php=LightnCandy::compile($template,array("flags"=>LightnCandy::FLAG_JSTRUE));echo$php

compile toecho 'a', $b, 'c' by default

Used option: FLAG_ECHO

Data:
NULL
Template:
A{{{foo}}}C
Result:
use \LightnCandy\Runtime as LR;return function ($in = null, $options = null) {    $helpers = array();    $partials = array();    $cx = array(        'flags' => array(            'jstrue' => false,            'jsobj' => false,            'jslen' => false,            'spvar' => false,            'prop' => false,            'method' => false,            'lambda' => false,            'mustlok' => false,            'mustlam' => false,            'mustsec' => false,            'echo' => true,            'partnc' => false,            'knohlp' => false,            'debug' => isset($options['debug']) ? $options['debug'] : 1,        ),        'constants' => array(),        'helpers' => isset($options['helpers']) ? array_merge($helpers, $options['helpers']) : $helpers,        'partials' => isset($options['partials']) ? array_merge($partials, $options['partials']) : $partials,        'scopes' => array(),        'sp_vars' => isset($options['data']) ? array_merge(array('root' => $in), $options['data']) : array('root' => $in),        'blparam' => array(),        'partialid' => 0,        'runtime' => '\LightnCandy\Runtime',    );        $inary=is_array($in);    ob_start();echo 'A',(($inary && isset($in['foo'])) ? $in['foo'] : null),'C';return ob_get_clean();};
Source Code
require('./vendor/autoload.php');useLightnCandy\LightnCandy;$template="A{{{foo}}}C";$php=LightnCandy::compile($template,array("flags"=>LightnCandy::FLAG_ECHO));echo$php

See Also...

Search the cookbook

Generated at 2022-03-21T13:13:56.019Z

[8]ページ先頭

©2009-2025 Movatter.jp