Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Shortcode Bundle Laravel Package

drinky78/shortcode-bundle

View on GitHub
Deep Wiki
Context7

Bundle that provides a Twig filter to support WordPress-like shortcodes.

Important: It's an early prototype!

Currently supported are tags of this form:

  • [demo] (simple tags)
  • [demo var=xxx var2=yyy] (tags with unquoted attributes)

Not yet supported are:

  • [demo]...[/demo] (tags with embedded content)
  • [demo var="xxx"] (tags with quoted attributes)

###Installation

Add ShortcodeBundle in your composer.json:

{
    "require": {
        "drinky78/shortcode-bundle": "dev-master"
    }
}

Register the bundle in AppKernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MW\Bundle\ShortcodeBundle\MWShortcodeBundle(),
    );
}

##How to use:

###1. Create a new shortcode handler

<?php

#MyProject\Bundle\TestBundle\Shortcode\DemoShortcode.php

namespace MyProject\Bundle\TestBundle\Shortcode;

use MW\Bundle\ShortcodeBundle\Shortcode\BaseShortcode;

class DemoShortcode extends BaseShortcode
{

    public function parse($options)
    {
        // TODO: Render your content
        return 'Shortcode content';
    }

}

###2. Define the shortcode as a service (the alias will be the name of your shortcode):

<service id="myproject.shortcode.demo" class="MyProject\Bundle\TestBundle\Shortcode\DemoShortcode">
    <tag name="mw.shortcode" alias="demo" />
</service>

YML example

parameters:
    myproject.shortcode.demo: MyProject\Bundle\TestBundle\Shortcode\DemoShortcode

services:
    myproject.shortcode.demo:
        class: %myproject.shortcode.demo%
        tags:
            - { name: mw.shortcode, alias: demo }

###3. Use it in your Twig templates

<div>{{ page.content|shortcodes }}</div>
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity