matejsvajger / laravel-mix-pug

Laravel Mix Plugin for compiling Pug/Jade templates.
MIT License
21 stars 23 forks source link

php syntax? #17

Closed jklue closed 4 years ago

jklue commented 4 years ago

Thanks so much for this plugin. Is there a shorthand to write PHP using this Laravel Mix package? I tried

.header
    -snippet('logo')
    -snippet('menu')

and I got the snippet is not a function error

matejsvajger commented 4 years ago

I'm guessing you only want to output snippet() as a string since it is a php function?

Then just use the pipe | operator and you should be fine:

.header
    | snippet('logo')
    | snippet('menu')

or in the case of for laravel blade:

.header
    | {{ snippet('logo') }}
    | {{ snippet('menu') }}
jklue commented 4 years ago

Sorry for the delay! I would like the output from the original post to be:

<header>
    <?php snippet('logo') ?>
    <?php snippet('menu' ?>
</header>

Unfortunately, the pipe operator is giving me the following, without adding the necessary PHP tags.

<header>snippet('logo') snippet('menu')</header

Edit: I wrote my own custom plugin, called :p so it returns the text wrapped in <?php and ?>. I'd like to shorten even further to - instead of :p but don't know how.