We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
require('./vendor/autoload.php'); use LightnCandy\LightnCandy; error_reporting(E_ALL); // The Template: $template = <<<VAREND {{#each itemList as |item|}} <svg class="m-stage__copyright-icon svg"><use xlink:href="{{../global.svgSprite}}#icon-camera"></use></svg> {{/each}} VAREND; $phpStr = LightnCandy::compile($template, array( // Used compile flags 'flags' => LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_HANDLEBARS, 'helpers' => [], 'partials' => [], )); echo "Generated PHP Code:\n$phpStr\n"; // Input Data: $data = array( 'itemList' => [ 0 => 'item1', ], // 'global' => [ // 'svgSprite' => 'somePath' // ], ); // Save the compiled PHP code into a php file file_put_contents('render.php', '<?php ' . $phpStr . '?>'); // Get the render function from the php file $renderer = include('render.php'); echo "Result:\n" . $renderer($data);
Generated PHP Code: use \LightnCandy\SafeString as SafeString;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' => true, '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 ''.LR::sec($cx, (($inary && isset($in['itemList'])) ? $in['itemList'] : null), array('item'), $in, true, function($cx, $in) {$inary=is_array($in);return ' <svg class="m-stage__copyright-icon svg"><use xlink:href="'.LR::encq($cx, ((isset($cx['scopes'][count($cx['scopes'])-1]) && is_array($cx['scopes'][count($cx['scopes'])-1]['global']) && isset($cx['scopes'][count($cx['scopes'])-1]['global']['svgSprite'])) ? $cx['scopes'][count($cx['scopes'])-1]['global']['svgSprite'] : null)).'#icon-camera"></use></svg> ';}).''; }; PHP Warning: Undefined array key "global" in /home/daniels/Projects/stuff/lightncandy/render.php on line 32 Result: <svg class="m-stage__copyright-icon svg"><use xlink:href="#icon-camera"></use></svg>
A PHP Warning on PHP 8.1 due to checking is_array() prior checking if the value exists at all. https://zordius.github.io/HandlebarsCookbook/0014-path.html
is_array()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The PHP Code:
The result
The Issue:
A PHP Warning on PHP 8.1 due to checking
is_array()
prior checking if the value exists at all.https://zordius.github.io/HandlebarsCookbook/0014-path.html
The text was updated successfully, but these errors were encountered: