Django + Pug(Jade) - how to pass object to mixin?

376 views Asked by At

I installed pypugjs, added it to settings.py, it works fine, but when I'm trying to pass object to Pug mixin - I got a TemplateSyntaxError -

Could not parse the remainder: '{age:20' from '{age:20'

mixin card(data)
    div #{data}

+card({age:20, name:'Alex'})

How to pass more than one named filed to Pug mixin in Django?

1

There are 1 answers

1
Andy On

you would do it like this:

mixin card(age, name)
  div {{ age }}, {{ name }}
+card(20, 'Alex')

or alternatively (i simplified to test my answer :)

mixin card(data)
  div {{ data.age }}, {{ data.name }}
+card(data)