Giter VIP home page Giter VIP logo

bemhtml-syntax's People

Contributors

vkz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

miripiruni bem

bemhtml-syntax's Issues

Templates that trip kcompiler

Is it ok to throw error or do we want some compiler magic to handle these?

  • Problem is with non-standard args to applyCtx:
block dropdown-menu {
    elem menu, default: {
        applyCtx(this._inDropdownMenu = true, {
            block: 'bla'
        });
    }
}
  • Problem with computed prop in the arg to applyNext:
block button, mod round yes {
    default: applyNext(
      this.ctx.mods['only-icon'] = 'bla'
   )
}

^^ @veged @arikon @tadatuta

Add tests for bem-xjst4 compatibility flags

  • assertHasBlock assert that every template has sub-predicate matching block
  • assertNoThisElem assert there're no predicates matching this.elem bem/bem-xjst#89
  • applySetsMode assert that every apply sets the mode as its first argument bem/bem-xjst#91
  • applyCheckFields warn when apply assigns block, elem, mods, elemMods bem/bem-xjst#73
  • returnFromDef ensure there's always return in def mode. Insert return '' when there is none
  • assertNoBuf assert this._buf is never used in templates

Regexp is broken after convert

Input file suggest-item_type_nav with BEMHTML:

block suggest-item, mod type nav {
    default: {
        var url = this.ctx.data[4];
        applyNext({_url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url});
    }
}

Run [email protected]:

$ bemhtml-syntax -i suggest-item_type_nav

Actual:

block('suggest-item').mod('type', 'nav')(
    def()(function() {
        var url = this.ctx.data[4];
        return applyNext({
            _url: (url.match('^\w[\w-]*:\/\/' // regexp turned to string
                g) ? '' : 'http://') + url 
        });
    }))

Expected:

block('suggest-item').mod('type', 'nav')(
    def()(function() {
        var url = this.ctx.data[4];
        return applyNext({
            _url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url
        });
    }))

Replace `BEMHTML.apply()` with `this.reapply()` preserving args

  • implement
  • should only be changed at top-level inside template body, DO NOT replace in closures
  • add test

before

block my-block, this._.isSimple(this.ctx): {
  return BEMHTML.apply(bla, a = 1);
}

after

block('my-block').match(function() {
    return this._.isSimple(this.ctx)
})(function() {
    return this.reapply(bla, a = 1);
})

Proper indentation

  • add a post-compilation pass that removes excessive \n in #spacesAndComments
  • each sub-template should start on a separate line

Make converter compatible with bem-xjst 4+

see https://github.yandex-team.ru/lego/islands/pull/509
Compatibility with the latest bem-xjst should be available with relevant flag in the API

  • assert that every template has sub-predicate matching block
  • assert there're no predicates matching this.elem bem/bem-xjst#89
  • assert that every apply sets the mode as its first argument bem/bem-xjst#91
  • warn when apply assigns block, elem, mods, elemMods bem/bem-xjst#73
  • convert def() + applyCtx with this.ctx inside into wrap() see article7 in https://github.yandex-team.ru/lego/islands/pull/509
  • ensure there's always return in def mode. Insert return '' when there is none
  • assert this._buf is never used in templates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.