Clean up your PHP templates and create simple data objects to render your Vue components and its props.
Never do the following ever again.
<v-slider :autoplay="<?php echo ($shouldAutoplay ? 'true' : 'false'); ?>">
<?php foreach ($sliderItems as $item): ?>
<v-slider-item src="<?php echo $item['src']; ?>"></v-slider-item>
<?php endforeach; ?>
</v-slider>
Instead, do this.
use mrcrmn\VueGenerator\Vue;
use mrcrmn\VueGenerator\VueCollection;
$slider = Vue::make('v-slider')->setProp('autoplay', true);
$slider->setSlot(new VueCollection([
Vue::make('v-slider-item')->setProp('src', 'image1.jpg'),
Vue::make('v-slider-item')->setProp('src', 'image2.jpg'),
]));
And then in your template.
<?php echo $slider; ?>
To install this package run the following command in your project's root.
$ composer require mrcrmn/vue-generator
For the docs visit https://mrcrmn.netlify.com/packages/vue-generator/