php-dom-wrapper
php-dom-wrapper copied to clipboard
disable attribute encoding
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"
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>
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>