Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two shortcodes in a row does not work? #56

Closed
jenstornell opened this issue Jan 26, 2018 · 4 comments
Closed

Two shortcodes in a row does not work? #56

jenstornell opened this issue Jan 26, 2018 · 4 comments
Assignees
Labels

Comments

@jenstornell
Copy link

jenstornell commented Jan 26, 2018

Error

Maybe I'm missing a setting or something but I can't get the thing below to work properly:

<?php
include 'vendor/autoload.php';

use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;

$facade = new ShortcodeFacade();
$facade->addHandler('hello', function(ShortcodeInterface $s) {
    return sprintf('Hello, %s!', $s->getParameter('name'));
});

$text = '
    <div class="users">
    [hello name="Thomas"]
    [hello name="Peter"]
    </div>
';
echo $facade->process($text);

The result will be:

<div class="users">
Hello, Thomas!
[hello name="Peter"]
</div>

Works

So when wrapping both shortcodes around a single div it will only parse the first one.

The strange thing is that this works:

(se full example above. I replaced the $text variable)

$text = '
    [hello name="Thomas"]
    [hello name="Peter"]
';

The result of the last test is:

Hello, Thomas!
Hello, Peter!
@thunderer
Copy link
Owner

Hi @jenstornell, thanks for using my library! Unfortunately, I am not able to reproduce this issue, so I need a little more context on your environment (OS, PHP version, Shortcode version). Can you provide such information?

I created a smallest composer.json with the latest Shortcode version (v0.6.5) { "require": { "thunderer/shortcode": "^0.6" } } and ran your script on PHP 5.6, 7.1, and 7.2. Each time I got a correct response with both shortcodes replaced.

@jenstornell
Copy link
Author

I did run this in cmd:

composer require thunderer/shortcode ^0.6

I use Windows with Apache 2.4.26 and PHP7.1.7 and it's installed with XAMPP.

@thunderer
Copy link
Owner

Let's have the discussion about your issues in #57, please comment and reply there. We will get back to this issue once we resolve #57.

@jenstornell
Copy link
Author

It works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants