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

using magnet to remove attribute resulting in bad render #19

Closed
doppynl opened this issue Oct 26, 2020 · 4 comments
Closed

using magnet to remove attribute resulting in bad render #19

doppynl opened this issue Oct 26, 2020 · 4 comments
Labels

Comments

@doppynl
Copy link

doppynl commented Oct 26, 2020

I'm upgrading an app that uses an older version of tinybutstrong, to a more recent version to get it to run on php7 (and 8) as well as start using composer.

I run into a possible bug when an attribute is to be removed from the template using magnet config. It could also be I'm doing something wrong.

I can reproduce the problem with a small bit of code+template.
The following started failing in 3.10.0. Using version 3.9.0 works just fine.

<?php
require __DIR__ . '/../tbs_3100/tbs_class.php';

$tbs = new clsTinyButStrong();
$tbs->loadTemplate(__DIR__ . '/template.html');

$items = [
    ['url' => '/wherever', 'target' => '_blank', 'follow' => 'nofollow', 'name' => 'just a label' ],
    ['url' => '/wherever', 'target' => '',       'follow' => '',         'name' => 'just a label' ],
    ['url' => '/wherever', 'target' => '',       'follow' => '',         'name' => 'just a label' ],
    ['url' => '/wherever', 'target' => '_blank', 'follow' => 'nofollow', 'name' => 'just a label' ],
];

$tbs->MergeBlock('items', $items);

echo PHP_EOL . $tbs->Source . PHP_EOL;

template.html :

<ul>
  [items;block=begin;bmagnet=ul]
  <li>
    <a href="[items.url;magnet=li]" target="[items.target;magnet=#]" rel="[items.follow;magnet=#]">
      [items.name;ope=upper1]
    </a>
  </li>
  [items;block=end]
</ul>

This results in the following output:

<ul>
  <li>
    <a href="/wherever" target="_blank" rel="nofollow">
      Just a label
    </a>
  </li>
  <li>
    <a href="/wherever">
      Just a label
    </a>
  </li>
  <li>
    <a href="/wherever"items.target;magnet=#]"items.follow;magnet=#]">
      Just a label
    </a>
  </li>
  <li>
    <a href="/wherever" target="_blank" rel="nofollow">
      Just a label
    </a>
  </li>
</ul>

As you can see the first 2 items go fine, but whenever it needs to remove the same attribute for the next row again it fails for some reason.
Am I doing something wrong here? or was a bug introduced in version 3.10 ?

Thanks.

@Skrol29
Copy link
Owner

Skrol29 commented Nov 3, 2020

That is a bug, I’m working it.

@Skrol29
Copy link
Owner

Skrol29 commented Nov 3, 2020

The bug is fixed with TBS version 3.12.2

@Skrol29 Skrol29 closed this as completed Nov 3, 2020
@Skrol29 Skrol29 added the bug label Nov 3, 2020
@doppynl
Copy link
Author

doppynl commented Nov 4, 2020

Thanks, that appears to have solved my issue.

The new version is not on packagist yet however, and I would like to install it with composer.
Can you trigger an update in packagist?

Or better, you can configure auto-updates on packagist, how is explained here: https://packagist.org/about#how-to-update-packages

@Skrol29
Copy link
Owner

Skrol29 commented Nov 4, 2020

I’ve triggered the update and also I’ve set up the webhook for the auto-update.

Thanks :-)

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