M
M
MajorTom692018-09-12 12:48:12
JavaScript
MajorTom69, 2018-09-12 12:48:12

How to make pug render based on boolean value?

there is a template for angular, written in jade / pug, there is a table that uses a cycle to display something inside each cell, the problem is this:
I made two mixins that need to be displayed depending on the response from the function that I set to a variable

mixin first
    p=0
mixin second
    p=1
- for (i=0; i < rows; i++)
   tr
   - for (j=0; j < cols; j++)
      td
      - var test = "{{testfunc(" + i + "," + j + ")}}"
      //var верно определяется если выводить его напрямую и может быть либо true либо false
     
     case test
        when true
           +first
        default
           +second
// и вот тут встречается проблема, в данном случае почемуто выводиться только один из mixin на все клетки, даже если значение не совпадает

5b98e0d061085994166680.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question