ariasbros/laravel-shortcode

Laravel Shortcode Service

dev-master 2017-09-05 06:44 UTC

This package is not auto-updated.

Last update: 2024-12-05 04:28:27 UTC


README

A implementation of shortcodes in a package for Laravel

'providers' => [
    AriasBros\Shortcode\Providers\ShortcodeServiceProvider::class,     
],

'aliases' => [
    "Shortcode" => AriasBros\Shortcode\Facades\Shortcode::class
],
use Shortcode;

Shortcode::composer("shortcode_tag", "App\Http\ViewShortcodes\MyShortcode");
use AriasBros\Shortcode\Contracts\Factory as ShortcodeFactory;

public function boot(ShortcodeFactory $shortcode)
{   
    $shortcode->composer("shortcode_tag", "App\Http\ViewShortcodes\MyShortcode");
}
<?php
    
namespace App\Http\ViewShortcodes;

use AriasBros\Shortcode\Contracts\Shortcode;

class MyShortcode implements Shortcode
{
    /**
     * @return Illuminate\View\View
     */
    public function compose($attrs = null)
    {
        return view("shortcodes.my-shortcode", $attrs);
    }
}