-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
The PHP Code:
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
// template doesn't matter
// Helpers:
$helpers = array(
'formatInt' => fn($value) => number_format($value)
);
$phpStr = LightnCandy::compile($template, array(
// Used compile flags
'flags' => LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_HANDLEBARS,
'helpers' => $helpers,
));
// Generated php code
use \LightnCandy\SafeString as SafeString;use \LightnCandy\Runtime as LR;return function ($in = null, $options = null) {
$helpers = array( 'formatInt' => $hb->addHelper('formatInt', fn($value) => number_format($value));
,
);
/// etc...
Results: ParseError: syntax error, unexpected token ";", expecting ")" on line 2
The Issue:
Arrow functions as helpers generate invalid php code
Simply changing to a full closure fixes the issue
theodorejb
Metadata
Metadata
Assignees
Labels
No labels