Skip to content

[major] BEM-XJST: modifier templates should apply before def()#490

Open
miripiruni wants to merge 2 commits into
masterfrom
issue-482__mod-templates
Open

[major] BEM-XJST: modifier templates should apply before def()#490
miripiruni wants to merge 2 commits into
masterfrom
issue-482__mod-templates

Conversation

@miripiruni

Copy link
Copy Markdown
Contributor

Fixes #482

@miripiruni
miripiruni requested a review from qfox October 30, 2017 15:45
@coveralls

coveralls commented Oct 30, 2017

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 99.306% when pulling 020fa6a on issue-482__mod-templates into ba102b7 on master.

@miripiruni

Copy link
Copy Markdown
Contributor Author

Looks like it’s patch… but I still have doubt about it.

Comment thread docs/en/5-templates-syntax.md Outdated
The `def` mode (short for "default") has a special status. It is responsible for generating the result as a whole. This mode defines the list of other modes and the order to go through them, as well as the build procedure for getting the final representation of the HTML element or BEMJSON from the parts generated in the other modes.

This is a special mode that shouldn’t be used unless truly necessary. A user-defined template that redefines `def` disables calls of the other modes by default.
This is a special mode that shouldn’t be used unless truly necessary. A user-defined template that redefines `def` disables calls of the other modes by default, exept `mods`, `elemMods`, `addMods` and `addElemMods`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zxqfox thanks!

@qfox qfox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@miripiruni
miripiruni force-pushed the issue-482__mod-templates branch from 020fa6a to fad15d2 Compare October 30, 2017 18:53
@coveralls

coveralls commented Oct 30, 2017

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 99.387% when pulling e542cd7 on issue-482__mod-templates into e76cd62 on master.

@miripiruni
miripiruni requested a review from tadatuta November 16, 2017 14:16
@miripiruni

miripiruni commented Jan 16, 2018

Copy link
Copy Markdown
Contributor Author

I want to check it on real front-end project with gemini tests. @tadatuta @zxqfox @sbmaxx who uses v8.x?

@sbmaxx

sbmaxx commented Jan 16, 2018

Copy link
Copy Markdown
Contributor

Turbo? ;)

@miripiruni
miripiruni force-pushed the issue-482__mod-templates branch 2 times, most recently from 8664edb to 12575ca Compare February 5, 2018 13:00
@miripiruni
miripiruni force-pushed the issue-482__mod-templates branch from 12575ca to 0892028 Compare February 5, 2018 13:02
@miripiruni

Copy link
Copy Markdown
Contributor Author

@zxqfox it’s a major changes.

Integration tests are red. https://nda.ya.ru/3TwoUQ

Template from turbo:

block('list')(
    def()((node, ctx) => applyNext({ items: [].concat(ctx.content || []) })),

    addMods()((node, ctx) => {
        const mods = { [ctx.ordered ? 'ordered' : 'unordered']: true };

        ctx.ordered && node.items.length > 10 && (mods['wide-numbers'] = true);

        // у ВинФонов в шрифтах нет некоторых символов, используемых для маркеров
        if ((node.data.reqdata.device_detect.OSFamily || '').toLowerCase() === 'windowsphone') {
            mods['alt-markers'] = true;
        }

        return mods;
    }),

    

@miripiruni miripiruni modified the milestones: 8.8.8, 9.0.0 Feb 5, 2018
@qfox

qfox commented Feb 5, 2018

Copy link
Copy Markdown
Member

Okay, let's consider this as breaking, but it's a bad code on their side, they can't guarantee they have items in node cuz there is no applyNext call.

😢 but true.

@miripiruni

Copy link
Copy Markdown
Contributor Author

PR is locked and waiting next major release.

@miripiruni miripiruni changed the title BEMXJST: modifier templates should apply before def() [major] BEM-XJST: modifier templates should apply before def() Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants