Как реализовать несколько блоков в mixin — pug?

Для того чтобы реализовать несколько блоков в mixin в Pug, можно использовать переменное количество аргументов и условные операторы.

Ниже приведен пример кода, демонстрирующий, как это можно сделать:

mixin multipleBlocks(args...)
block1
- if(args[0])
| This is the first block with the argument #{args[0]}
- else
| This is the default content for the first block

block2
- if(args[1])
| This is the second block with the argument #{args[1]}
- else
| This is the default content for the second block

block3
- if(args[2])
| This is the third block with the argument #{args[2]}
- else
| This is the default content for the third block

Теперь можно вызывать этот mixin, передавая аргументы для каждого блока. Например:

+multipleBlocks('Argument 1', 'Argument 2')

В результате будет сгенерирован следующий HTML-код:

block1
This is the first block with the argument Argument 1

block2
This is the second block with the argument Argument 2

block3
This is the default content for the third block

Если вызвать mixin без аргументов:

+multipleBlocks()

То будет сгенерирован следующий HTML-код:

block1
This is the default content for the first block

block2
This is the default content for the second block

block3
This is the default content for the third block

Таким образом, можно создавать несколько блоков в mixin и передавать им аргументы для генерации различного контента.