Skip to content

mrcrmn/vue-generator

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

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/

About

Data objects to generate HTML for Vue components

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages