bem / bh-php

PHP port of https://github.com/bem/bh. It's cool thing but better use this:
https://github.com/zxqfox/php-fpm-bem-demo-heroku
MIT License
34 stars 9 forks source link

Demo executable code needed #19

Open jasonrgd opened 9 years ago

jasonrgd commented 9 years ago

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

qfox commented 9 years ago

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>