Skip to content

Releases: DevGroup-ru/bh-php

Unsafe attrs and cls

05 May 22:41
Compare
Choose a tag to compare

New BC-breaking feature added: ability to store unsafe(unescaped) values in attrs and cls.
Example of unsafe stuff:

<?php
$bemjson = [
     'block' => 'myblock',
     'cls' => [
         'unsafe' => '<?= isset($item["red"])?"red":"" ?>',
     ],
     'attrs' => [
         'data-key' => [
             'unsafe' => '<?= $key ?>',
         ],
     ],
 ];
echo $bh->apply($bemjson);

Will produce:

<div class="myblock <?= isset($item["red"])?"red":"" ?>" data-key="<?= $key ?>"></div>

Which is good for PHP-templates.