hubsta / acf-snippet-vsc

11 stars 9 forks source link

Feature Request: add Laravel Blade support #10

Open andreabrunato opened 5 years ago

andreabrunato commented 5 years ago

I use ACF a lot with templates written in blade (.blade.php), it will be cool to have this extension available also for Blade. Any plans? Thanks a lot.

michaelmano commented 5 years ago

@andreabrunato I use blade with Laravel a lot, Just curious would the below be correct:

Instead of the below

<?php

if( get_field('colors') ): ?>
<ul>
    <?php foreach( get_field('colors') as $color ): ?>
        <li><?php echo $color; ?></li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

it would then be


@if( get_field('colors') )
<ul>
  @foreach( get_field('colors') as $color )
    <li>{{ $color }}</li>
  @endforeach
</ul>
@endif
andreabrunato commented 5 years ago

It seems correct, anyway what kind of field is "colors"? In the ACF documentation they often use while and subfields. Not sure how your answer is related to my request 🤔

michaelmano commented 5 years ago

Well my question was checking if you just wanted the current snippets to work inside of blade files OR a new set of snippets for the blade style, it seems we would need a new set of snippets which is fine. ill take a look at converting them :)

andreabrunato commented 5 years ago

A new set of snippets is way better! Thanks a lot! 🙏

michaelmano commented 5 years ago

@andreabrunato would you happen to know which plugin or theme you are using which enables blade templating so I can test out if the new snippets work as intended.

andreabrunato commented 5 years ago

I use Roots Sage 9 with ACF 5.8 PRO

In VScode I have this plugins enabled for Blade. 'laravel-blade' plugin: https://marketplace.visualstudio.com/items?itemName=cjhowe7.laravel-blade 'Laravel Blade Snippets' plugin: https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade

Maybe it's better to use this syntax for some fields outputs which can be WYSIWYG editor: {!! get_field('text') !!} to output HTML well. And use {{ }} for fields like <img src="{{ get_field('image_url') }}">

andreabrunato commented 5 years ago

Hi! Any update on this? :) I've seen the blade branch, great work! Will you merge it? Can I help somehow?

1pix commented 4 years ago

+1 , thx !