bem / bem/bem-xjst

Helper to check property existence in ctx and in this

Open
#336 4 comments 0 reactions 0 assignees View on GitHub
contribution welcome scope: semantic status: ready type: new feature
Dominant language
JavaScript
Stars
117
Forks
47
PR merge metrics
No merged PRs in 30d

Description

Something like:

``` js
block('b42').match(function() { return this.ctx.icon; }).tag()('b')
// →
block('b42').has('icon').tag()('img')
```

and maybe like (or params/guards?):

``` js
block('b43').mod('flagged', 'yes')(function() {
this._icon = true;
return applyNext();
});
block('b42').match(function() { return this._icon; }).tag()('b')
// →
block('b43').mod('flagged', 'yes')(node => (node.flag('icon', true), applyNext()));
block('b42').hasFlag('icon').tag()('img');
```

And if we need negation (in addition to #246):

``` js
block('b42').match(function() { return !this.ctx.content; }).content()('default content');
block('b42').not(has('content')).content()('default content');
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing match(), mod(), ctx, and flag behavior described in the examples, along with the related issue #246. Done would require an agreed helper syntax and semantics for checking properties or flags on ctx and this, including the proposed negation form.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.