Forums

Give help. Get help.

  • # January 16, 2015 at 2:54 am

    Just a quick question about the above that has been buzzing around our office today.

    I am fairly new to LESS and very new to BEM methodology so wanted to bounce the idea off some experts to find out pros/cons. The idea being this:

    If I write using the BEM methodology in LESS I can write like this:

    block {
      &__element {
        &--modifier-one {
           color: red;
        }
        &--modifier--two {
           color: blue;
        }
      }
    }
    

    that will compile to:

    block__element--modifier-one {
      color: red;
    }
    block__element--modifier-two {
      color: blue;
    }
    

    Now to me that seems like a nice way of writing it within less and it will also make it easier to maintain in the long run but a quick web search hasn’t bought anything up and that makes me worry that I have overlooked something very important!

    What do you guys think?

    # January 23, 2015 at 11:31 am

    Seems perfectly fine to me. I just covered that a little in this article in the nesting section. Good to know LESS works the same way.

    # January 24, 2015 at 2:51 am

    My team have just been discussing this very issue and have decided to go for it.

    It links things to better really nicely so we think it will be good for us.

    # September 13, 2018 at 1:15 pm

    Hey I know this is old, but you have a bug in

    &--modifier--two {
    

    Should be

    &--modifier-two {
    

    :)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag