Home computickets Blocks in Mixin PUG

Blocks in Mixin PUG

Author

Date

Category

There is such a mixing button

- var blocks = {};
MIXIN SET (KEY)
 - Blocks [Key] = this.block
Mixin A (ButtonClass, Buttontext, Disabled)
 Button.Button (Class = Buttonclass, disabled = disabled)
  span
   If block
    block
    - Blocks.left ()
    | # {beuttontext}
    - Blocks.Right ()
   ELSE.
    | # {beuttontext}
+ A ("Button_small Button_Filled", "Button", False)
 + set ('left')
  P L.
 + set ('right')
  P R.

This mixing worker, but it works a bit different, as I would like.
I can not figure out how to fix.

The idea is such that set (‘left’) is to insert into the button, the icon on the left.
+ Set (‘Right’) – Icon with the right

If I write + set (‘left’) and + set (‘right’) as an example, everything is ok.
But if I write something one, then mistake.

https://codepen.io/inkshio/pen/ybvomk


Answer 1

Maybe someone come in handy

// -
  Mixing buttons
  ButtonClass - Button Style
  Buttontext - button text
  Disabled - active button or not (True, False)
Mixin Button (ButtonClass, Buttontext, Disabled)
  // - to output multiple blocks in mixing
  - var iCons = {};
  MIXIN SET (KEY)
    - ICONS [KEY] = THIS.BLOCK
  Button.Button (Class = Buttonclass, disabled = disabled)
    span.button__Content
      If block
        block
        - if (icons.left) {
          span.button__icon.
            - icons.left ()
        - }
        span.button__Text
          | # {beuttontext}
        - if (icons.right) {
          span.button__icon.
            - icons.right ()
        - }
      ELSE.
        span.button__Text
          | # {beuttontext}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions