beebmx / kirby-blade

Enable Blade for Kirby 3 & 4
MIT License
15 stars 3 forks source link

Directives: Do they work? #8

Closed adamkiss closed 3 years ago

adamkiss commented 3 years ago

I wasn't able to make any of the directives Work.

Looking at the:

It seems that directives by default don't parse the $parameters, you have to do it yourself. In these cases the correct version of the e.g. gist directive would be:

  'gist' => function($expression) {
     return "<?= gist($expression) ?>";
  }

Basically, just passing the expression in the Blade Templates through.

Am I wrong?

beebmx commented 3 years ago

The directives should be in the beebmx.kirby-blade.directives key in the config.php file:

'beebmx.kirby-blade.directives' => [
    'gist' => function ($expression) {
        return "<?php echo gist($expression); ?>";
    }
],
adamkiss commented 3 years ago

That is not what I meant;

The default ones, like: https://github.com/beebmx/kirby-blade/blob/18db9c54b5e4514625855f30186c5e26ce25f3cc/src/Template.php#L124 don't actually work.

@esc('one', 'attr', true)

renders as

<?php echo esc('one', 'attr', true, html, ) ?>

which is obviously wrong