Laravel Shortcodes Package
Laravel | Shortcodes |
---|---|
5.0.x | 1.0.x |
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',
[example foo="something"]
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']}";
});
To render the view and compile the Shortcodes:
return view('view')->compileShortcodes();
To render the view and remove the Shortcodes
return view('view')->stripShortcodes();
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).