Muhammad97 / laravel-shortcodes-1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel-Shortcodes

Laravel Shortcodes Package

Laravel compatibility

Laravel Shortcodes
5.0.x 1.0.x

Installation

Require this package in your composer.json and update composer.

"gornymedia/shortcodes": "1.*"

Add the service provider to app/config/app.php

'Gornymedia\Shortcodes\ShortcodesServiceProvider',

Add the class alias to app/config/app.php

'Shortcode' => 'Gornymedia\Shortcodes\Facades\Shortcode',

Demo

[example foo="something"]

Usage

Creating shortcodes

Inside a service provider you can create the shortcodes with attributes.

Shortcode::add('example', function($atts, $content, $name)
{
  $a = Shortcode::atts(array(
    'foo' => 'something',
    'bar' => 'something else',
    ), 
    $atts
  );
    return "foo = {$a['foo']}";
});

View rendering

compileShortcodes()

To render the view and compile the Shortcodes:

return view('view')->compileShortcodes();

stripShortcodes()

To render the view and remove the Shortcodes

return view('view')->stripShortcodes();

License

This package is open-source software licensed under MIT License.

This package uses WordPress shortcodes methods. The license under which the WordPress software is released is the GPLv2 (or later).

About

License:MIT License


Languages

Language:PHP 100.0%