dev-master
9999999-devBundle that provides a Twig filter to support WordPress-like shortcodes.
MIT
The Requires
- symfony/framework-bundle >=2.2
- php >=5.3.3
shortcode
Bundle that provides a Twig filter to support WordPress-like shortcodes.
Bundle that provides a Twig filter to support WordPress-like shortcodes., (*1)
Important: It's an early prototype!, (*2)
Currently supported are tags of this form:
* [demo]
(simple tags)
* [demo var=xxx var2=yyy]
(tags with unquoted attributes), (*3)
Not yet supported are:
* [demo]...[/demo]
(tags with embedded content)
* [demo var="xxx"]
(tags with quoted attributes), (*4)
Add MWShortcodeBundle in your composer.json:, (*5)
{ "require": { "mw/shortcode-bundle": "dev-master" } }
Register the bundle in AppKernel, (*6)
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new MW\Bundle\ShortcodeBundle\MWShortcodeBundle(), ); }
``` php <?php, (*7)
namespace MyProject\Bundle\TestBundle\Shortcode;, (*8)
use MW\Bundle\ShortcodeBundle\Shortcode\BaseShortcode;, (*9)
class DemoShortcode extends BaseShortcode {, (*10)
public function parse($options) { // TODO: Render your content return 'Shortcode content'; }
}, (*11)
###2. Define the shortcode as a service (the alias will be the name of your shortcode): ``` xml <service id="myproject.shortcode.demo" class="MyProject\Bundle\TestBundle\Shortcode\DemoShortcode"> <tag name="mw.shortcode" alias="demo" /> </service>
YML example, (*12)
parameters: myproject.shortcode.demo: MyProject\Bundle\TestBundle\Shortcode\DemoShortcode services: myproject.shortcode.demo: class: %myproject.shortcode.demo% tags: - { name: mw.shortcode, alias: demo }
html
<div>{{ page.content|shortcodes }}</div>
, (*13)
Bundle that provides a Twig filter to support WordPress-like shortcodes.
MIT
shortcode