boolString() public static method

return 'true' or 'false' string.
public static boolString ( integer $v ) : string
$v integer value
return string 'true' when the value larger then 0
Esempio n. 1
0
    /**
     * Compose LightnCandy render codes for include()
     *
     * @param array<string,array|string|integer> $context Current context
     * @param string $code generated PHP code
     *
     * @return string Composed PHP code
     */
    public static function composePHPRender($context, $code)
    {
        $flagJStrue = Expression::boolString($context['flags']['jstrue']);
        $flagJSObj = Expression::boolString($context['flags']['jsobj']);
        $flagSPVar = Expression::boolString($context['flags']['spvar']);
        $flagProp = Expression::boolString($context['flags']['prop']);
        $flagMethod = Expression::boolString($context['flags']['method']);
        $flagLambda = Expression::boolString($context['flags']['lambda']);
        $flagMustlok = Expression::boolString($context['flags']['mustlok']);
        $flagMustlam = Expression::boolString($context['flags']['mustlam']);
        $flagEcho = Expression::boolString($context['flags']['echo']);
        $flagPartNC = Expression::boolString($context['flags']['partnc']);
        $flagKnownHlp = Expression::boolString($context['flags']['knohlp']);
        $constants = Exporter::constants($context);
        $helpers = Exporter::helpers($context);
        $partials = implode(",\n", $context['partialCode']);
        $debug = Runtime::DEBUG_ERROR_LOG;
        $use = $context['flags']['standalone'] ? Exporter::runtime($context) : "use {$context['runtime']} as {$context['runtimealias']};";
        $safeString = $context['usedFeature']['enc'] > 0 && $context['flags']['standalone'] === 0 ? "use {$context['safestring']} as SafeString;" : '';
        $exportSafeString = $context['usedFeature']['enc'] > 0 && $context['flags']['standalone'] > 0 ? Exporter::safestring($context) : '';
        // Return generated PHP code string.
        return <<<VAREND
{$safeString}{$use}{$exportSafeString}return function (\$in = null, \$options = null) {
    \$helpers = {$helpers};
    \$partials = array({$partials});
    \$cx = array(
        'flags' => array(
            'jstrue' => {$flagJStrue},
            'jsobj' => {$flagJSObj},
            'spvar' => {$flagSPVar},
            'prop' => {$flagProp},
            'method' => {$flagMethod},
            'lambda' => {$flagLambda},
            'mustlok' => {$flagMustlok},
            'mustlam' => {$flagMustlam},
            'echo' => {$flagEcho},
            'partnc' => {$flagPartNC},
            'knohlp' => {$flagKnownHlp},
            'debug' => isset(\$options['debug']) ? \$options['debug'] : {$debug},
        ),
        'constants' => {$constants},
        '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' => '{$context['runtime']}',
    );
    {$context['renderex']}
    {$context['ops']['op_start']}'{$code}'{$context['ops']['op_end']}
};
VAREND;
    }
Esempio n. 2
0
 /**
  * Compose LightnCandy render codes for include()
  *
  * @param array<string,array|string|integer> $context Current context
  * @param string $code generated PHP code
  *
  * @return string Composed PHP code
  */
 public static function composePHPRender($context, $code)
 {
     $flagJStrue = Expression::boolString($context['flags']['jstrue']);
     $flagJSObj = Expression::boolString($context['flags']['jsobj']);
     $flagSPVar = Expression::boolString($context['flags']['spvar']);
     $flagProp = Expression::boolString($context['flags']['prop']);
     $flagMethod = Expression::boolString($context['flags']['method']);
     $flagLambda = Expression::boolString($context['flags']['lambda']);
     $flagMustlok = Expression::boolString($context['flags']['mustlok']);
     $flagMustlam = Expression::boolString($context['flags']['mustlam']);
     $flagEcho = Expression::boolString($context['flags']['echo']);
     $flagPartNC = Expression::boolString($context['flags']['partnc']);
     $flagKnownHlp = Expression::boolString($context['flags']['knohlp']);
     $libstr = Exporter::runtime($context);
     $constants = Exporter::constants($context);
     $helpers = Exporter::helpers($context);
     $bhelpers = Exporter::helpers($context, 'blockhelpers');
     $hbhelpers = Exporter::helpers($context, 'hbhelpers');
     $partials = implode(",\n", $context['partialCode']);
     $debug = Runtime::DEBUG_ERROR_LOG;
     $phpstart = $context['flags']['bare'] ? '' : "<?php use {$context['runtime']} as LR;\n";
     $phpend = $context['flags']['bare'] ? ';' : "\n?>";
     // Return generated PHP code string.
     return "{$phpstart}return function (\$in, \$options = null) {\n    \$cx = array(\n        'flags' => array(\n            'jstrue' => {$flagJStrue},\n            'jsobj' => {$flagJSObj},\n            'spvar' => {$flagSPVar},\n            'prop' => {$flagProp},\n            'method' => {$flagMethod},\n            'lambda' => {$flagLambda},\n            'mustlok' => {$flagMustlok},\n            'mustlam' => {$flagMustlam},\n            'echo' => {$flagEcho},\n            'partnc' => {$flagPartNC},\n            'knohlp' => {$flagKnownHlp},\n            'debug' => isset(\$options['debug']) ? \$options['debug'] : {$debug},\n        ),\n        'constants' => {$constants},\n        'helpers' => {$helpers},\n        'blockhelpers' => {$bhelpers},\n        'hbhelpers' => isset(\$options['helpers']) ? array_merge({$hbhelpers}, \$options['helpers']) : {$hbhelpers},\n        'partials' => array({$partials}),\n        'scopes' => array(),\n        'sp_vars' => isset(\$options['data']) ? array_merge(array('root' => \$in), \$options['data']) : array('root' => \$in),\n        'blparam' => array(),\n        'runtime' => '{$context['runtime']}',\n{$libstr}\n    );\n    {$context['renderex']}\n    {$context['ops']['op_start']}'{$code}'{$context['ops']['op_end']}\n}{$phpend}";
 }