0

I want to display a block/call mixin only if some condition is true. This is my code:

block details
                - var details = get_coverage_details()
                - var flag_display = all(value == [] for value in details.values())
                if not flag_display:
                    +details(details)

get_coverage_details is some python method in my code, which is getting me the dynamic content.

I am getting an error:

TemplateSyntaxError: expected token ',', got 'for'

The problem seems to be here all(value == [] for value in details.values())

ncica
  • 7,015
  • 1
  • 15
  • 37
S.K
  • 480
  • 1
  • 4
  • 19

2 Answers2

1

change

if not flag_display:
    +details(details)

to

if !flag_display
    +details(details)
0

I got this error because I was trying to use a Python method in a Jinja2 template that Jinja2 didn't support (in my case, any(), but I imagine it would also apply to all()).

See @flazzarini's answer here.

CodeBiker
  • 2,985
  • 2
  • 33
  • 36