neokoenig / cfwheels-shortcodes

A Shortcodes plugin for cfwheels
MIT License
5 stars 2 forks source link

Nesting shortcodes #2

Open timsayshey opened 9 years ago

timsayshey commented 9 years ago

I know this isn't available yet but I have a usecase.

[bootstrap type="row"] [bootstrap type="col" width="6" size="md"] My First Column! [/bootstrap] [bootstrap type="col" width="6" size="md"] My Second Column! [/bootstrap] [/bootstrap]

Is nesting a possible future enhancement or is it impossible?

neokoenig commented 9 years ago

it's highly possible. If you look at the original implementation, that's what Barney does - I just didn't have the time to implement it. it involves recalling the shortcode function from within the shortcode.

timsayshey commented 8 years ago

Tried my hand at it today but was unable to get it working.

However I did find a shortcodes cfc that handles nesting.

It might help you get it working: http://www.barneyb.com/barneyblog/2010/03/13/wordpress-shortcodes-in-cfml/

neokoenig commented 8 years ago

That's what I based it off in the first place!! ;)

On 28 Aug 2015, at 17:16, Tim Badolato notifications@github.com wrote:

Tried my hand at it today but was unable to get it working.

However I did find a shortcodes cfc that handles nesting.

It might help you get it working: http://www.barneyb.com/barneyblog/2010/03/13/wordpress-shortcodes-in-cfml/

— Reply to this email directly or view it on GitHub.

timsayshey commented 8 years ago

Lol, oh man...

I just reimplemented the whole plugin using his code, apparently even though he has tests for nested tags, they don't actually parse nested content. Well, switching back to yours since the code is way prettier :)

Okay, so I figured out a work around for now, calling processShortcodes(content) inside the shortcode.

Also, you can't nest the same shortcode, ie [bootstrap type="row"] [bootstrap type="col"] test [/bootstrap][/bootstrap] because it doesn't parse it right. But you can nest two different shortcodes, ie[bootstrap type="row"] [bootgrid col="12"] test [/bootgrid] [/bootstrap]

neokoenig commented 8 years ago

:) Yeah, I do the process shortcodes inside the shortcode thing. Works ok for simple stuff!

On 28 Aug 2015, at 17:54, Tim Badolato notifications@github.com wrote:

Lol, oh man...

I just reimplemented the whole plugin using his code, apparently even though he has tests for nested tags, they don't actually parse nested content. Well, switching back to yours since the code is way prettier :)

Okay, so I figured out a work around for now, calling processShortcodes(content) inside the shortcode.

Also, you can't nest the same shortcode, ie [bootstrap type="row"] [bootstrap type="col"] test [/bootstrap][/bootstrap] because it doesn't parse it right. But you can nest two different shortcodes, ie[bootstrap type="row"] [bootgrid col="12"] test [/bootgrid] [/bootstrap]

— Reply to this email directly or view it on GitHub https://github.com/neokoenig/cfwheels-shortcodes/issues/2#issuecomment-135831303.

neokoenig commented 8 years ago

PS, if you’re implementing Bootstrap grids, you really do need to check out gridmanager.js :P [shameless plug]

On 28 Aug 2015, at 17:54, Tim Badolato notifications@github.com wrote:

Lol, oh man...

I just reimplemented the whole plugin using his code, apparently even though he has tests for nested tags, they don't actually parse nested content. Well, switching back to yours since the code is way prettier :)

Okay, so I figured out a work around for now, calling processShortcodes(content) inside the shortcode.

Also, you can't nest the same shortcode, ie [bootstrap type="row"] [bootstrap type="col"] test [/bootstrap][/bootstrap] because it doesn't parse it right. But you can nest two different shortcodes, ie[bootstrap type="row"] [bootgrid col="12"] test [/bootgrid] [/bootstrap]

— Reply to this email directly or view it on GitHub https://github.com/neokoenig/cfwheels-shortcodes/issues/2#issuecomment-135831303.