Beispiel #1
0
 /**
  * Выполняет преобразования данного BEMJSON-элемента остальными шаблонами.
  * Может понадобиться, например, чтобы добавить элемент в самый конец содержимого,
  * если в базовых шаблонах в конец содержимого добавляются другие элементы.
  * Пример:
  * ```javascript
  * bh.match('header', function(ctx) {
  *    ctx.content([
  *        ctx.content(),
  *        { elem: 'under' }
  *    ], true);
  * });
  * bh.match('header_float_yes', function(ctx) {
  *    ctx.applyBase();
  *    ctx.content([
  *        ctx.content(),
  *        { elem: 'clear' }
  *    ], true);
  * });
  * ```
  *
  * @return Context
  */
 public function applyBase()
 {
     $node = $this->node;
     $json = $node->json;
     $block = $json->block;
     $blockMods = $json->mods;
     /** @var \Closure $fm */
     $subRes = $this->bh->matcherImpl($this, $json);
     if ($subRes !== null) {
         $this->ctx = $node->arr[$node->index] = $node->json = JsonCollection::normalize($subRes);
         $node->block = $block;
         // need check
         $node->mods = $blockMods;
     }
     return $this;
 }