S
S
Sergey2019-04-22 20:29:01
Pug
Sergey, 2019-04-22 20:29:01

How do I set an optional argument in a Pug mixin?

There is a mixin:

mixin select(length=5)
  select
    - for (var i = 1; i <= length; i++)
      option(value=i)= i

It needs to accept a class as an optional argument.
For example when calling:
+select(class="my-class")

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WapSter, 2019-04-22
@SergeiB

mixin select(value, length=5, elClass)
  - elClass = elClass || ''
  select(class = elClass)
    - for (var i = 1; i <= length; i++)
      option(value=i)= i

A
Arseny, 2019-04-22
Matytsyn @ArsenyMatytsyn

Everything is in the help starting from here .
Internally, it can be used with or without explicit binding.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question