Open a-liashenko opened 4 years ago
require('../vendor/autoload.php'); use LightnCandy\LightnCandy; $fileName = "lightncandy_" . (intval(microtime(true) * 1000)) . ".php"; $tmpl = "{{{{raw}}}} {{bar}} {{{{/raw}}}} {{bar}}"; echo "The template is : $tmpl\n"; $phpStr = LightnCandy::compile($tmpl, array( 'helpers' => array( // THE MISSING RAW HELPER HERE..... 'raw' => function ($op) { return $op['fn'](); } ), 'flags' => LightnCandy::FLAG_ERROR_LOG | LightnCandy::FLAG_SLASH | LightnCandy::FLAG_RAWBLOCK )); $filePath = 'tmp_' . $fileName; file_put_contents($filePath, '<?php ' . $phpStr . ' ?>'); $renderer = include($filePath); unlink($filePath); $variables = [ 'bar' => "content" ]; $html = $renderer($variables); echo $html;
The JS reference: https://jsfiddle.net/1bn4vktm/2/
Look's like after any {{{{raw}}}} {{{{/raw}}}} block all other template variables are ignored. JS code output: {{{{raw}}}} {{bar}}} {{{{/raw}}}} {{bar}} ---> {{bar}}} content PHP code output: {{{{raw}}}} {{bar}} {{{{/raw}}}} {{bar}} ---> {{bar}} {{bar}}
{{{{raw}}}} {{{{/raw}}}}
{{{{raw}}}} {{bar}}} {{{{/raw}}}} {{bar}}
{{bar}}} content
{{{{raw}}}} {{bar}} {{{{/raw}}}} {{bar}}
{{bar}} {{bar}}
Am I missing something?
The PHP Code:
The Issue:
The JS reference: https://jsfiddle.net/1bn4vktm/2/
Look's like after any
{{{{raw}}}} {{{{/raw}}}}
block all other template variables are ignored. JS code output:{{{{raw}}}} {{bar}}} {{{{/raw}}}} {{bar}}
--->{{bar}}} content
PHP code output:{{{{raw}}}} {{bar}} {{{{/raw}}}} {{bar}}
--->{{bar}} {{bar}}
Am I missing something?