mrcrmn/vue-generator

Generates HTML for Vue Components

v0.1.3 2019-03-30 12:39 UTC

This package is auto-updated.

Last update: 2020-06-30 01:13:02 UTC


README

68747470733a2f2f6d7263726d6e2e6e65746c6966792e636f6d2f7675652d67656e657261746f725f6c6f676f2e706e67

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/