bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
115 stars 47 forks source link

Error while apply() inside match #309

Closed Yeti-or closed 7 years ago

Yeti-or commented 8 years ago

I don't think that it is good pattern but when you try to use apply inside match u get an Error: example

Maybe we need to handle this error and continue to process template, or fix this.

miripiruni commented 8 years ago

We need a guard against recursion deadlock.

golyshevd commented 7 years ago

Another example https://goo.gl/EbKDW3

miripiruni commented 7 years ago

@golyshevd thank you. In current bem-xjst you can not use apply() in match().

golyshevd commented 7 years ago

@miripiruni why not? is it feature? )

miripiruni commented 7 years ago

@golyshevd it happened :) I’ll try to fix it.

golyshevd commented 7 years ago

@miripiruni Thanks!

remnev commented 7 years ago

Guys, let's resurrect this issue. We encountered this problem again.

miripiruni commented 7 years ago

@remnev can you show your usecase please?

golyshevd commented 7 years ago
block('foo')(
    mode('is-empty')(true),
    content()(
      match(() => !apply('is-empty'))('text')
    )
);
remnev commented 7 years ago

For example, I have a mode, which returns some data or nothing. Depends on it I want to output different content.

// one case: returns "text"
block('foo')(
    mode('is-empty')(true),
    content()(
      '–',
      match(() => apply('is-empty'))('text')
    )
);

// another case: returns "–"
block('foo').mod('a', 'b')(
    mode('is-empty')(false)
);
miripiruni commented 7 years ago

@remnev thanks.