Skip to content

Wrapping content within shortcodes? #4

@DevJMD

Description

@DevJMD

In your second example, you use:

[text color="red"]This is red text.[/text]

What if This is red text. is dynamic content? Take for example, a wrapper element.

HTML:

<div class="wrapper"></div>

Shortcode:

[wrapper] My dynamic content that could contain lots of HTML from the user [/wrapper]

How would I go about this? For example, My dynamic content is injected within <div class="wrapper"> My dynamic content </div>?

Maybe I'm overthinking this, but I want to use this in a WYSIWYG and I know a very similar service for Laravel lets you access the $content within the tags which renders anything between the shortcode tags.

The idea I have in my head is:

<div class="wrapper">{{ content }}</div>

Thus dynamically rendering the content between [wrapper] and [/wrapper].

Is there a way to achieve this or access the content within the shortcode tags?

I'm going to take a slight guess and presume this may involve passing the content as a controller argument somehow?

It's not that I want to inject content as such by parameter, but HTML pre-existing through the WYSIWYG.

Cheers,
J

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions