bem/bh-php

Demo executable code needed

jasonrgd opened this issue · 1 comments

it would be nice to have some form of demo code which can be directly executed on download.

qfox commented

Something like this?

require('vendor/bem/bh/index.php');
$bh = new BEM/BH();
$bh->match('type1', function ($ctx, $json) {
  $ctx->tag('button');
});
$bh->match('type2', function ($ctx, $json) {
  $ctx->attrs(['id' => 12]);
});
echo $bh->apply([
  ['block' => 'type1'],
  ['block' => 'type2'],
]);
// will render: <button class="type1"></button><div class="type2" id="12"></div>