Open andreabrunato opened 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
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 🤔
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 :)
A new set of snippets is way better! Thanks a lot! 🙏
@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.
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') }}">
Hi! Any update on this? :) I've seen the blade branch, great work! Will you merge it? Can I help somehow?
+1 , thx !
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.