php-dom-wrapper icon indicating copy to clipboard operation
php-dom-wrapper copied to clipboard

disable attribute encoding

Open doonfrs opened this issue 3 years ago • 2 comments
trafficstars

Hi; I am trying to set the href attribute to {{modelItem.finalUrl}}, as variable for PHP template. The library automatically encodes the {characters, anyway, to disable this feature?

$element->attr($attr, "{{modelItem.$bindValue}}"); result: href="%7B%7BmodelItem.finalUrl%7D%7D"

doonfrs avatar May 10 '22 00:05 doonfrs

Do you have a snippet that can replicate the issue? Did a quick test with the following at it generated the correct output:

Snippet:

use DOMWrap\Document;

$doc = (new Document())->html('<div></div>');
$doc->find('div')->attr('class', '{{modelItem.$bindValue}}');

echo $doc->html();

Output:

<html><body><div class="{{modelItem.$bindValue}}"></div></body></html>

scotteh avatar May 14 '22 06:05 scotteh

Thank you for reply, It worked well on class attribute, the problem appears on img src attribute

        $doc->find('div')->attr('class','{{myclass}}');
        $doc->find('img')->attr('src','{{mysrc}}');
        $html = $doc->html();
        var_dump($html);die();

output

<div id="ifcpi" class="{{myclass}}">
<img id="ikfed" src="%7B%7Bmysrc%7D%7D" alt="{{modelItem.WebsiteTitle}}">
 </div>

doonfrs avatar Jul 11 '22 08:07 doonfrs