Skip to content

mrcrmn/vue-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue Generator

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; ?>

Installation

Composer

To install this package run the following command in your project's root.

$ composer require mrcrmn/vue-generator

Docs

For the docs visit https://mrcrmn.netlify.com/packages/vue-generator/