0

Is there a way to use pug with Django when the pug templates use mixins that receive arguments? I'm trying to use pypugjs to create django templates from pug templates.

e.g: I have a template with the following mixin syntax:

+navbar({
    navbarBg: 'bg-transparent',
    navbarStyle: 'navbar-dark',
    navbarBrandColor: 'text-white',
    navbarBtnColor: 'btn-teal',
    navbarContainer: 'container',
    navbarPosition: 'fixed-top'
})

which gives the following error:

unexpected token "attrs" in file sb-ui-kit-pro/src/pug/pages/index.pug on line 18

If I reformat the mixin block to the following (so that the mixin is all on one line):

+navbar({ navbarBg: 'bg-transparent', navbarStyle: 'navbar-dark', navbarBrandColor: 'text-white', navbarBtnColor: 'btn-teal', navbarContainer: 'container', navbarPosition: 'fixed-top' })

then I get the following error:

The mixin blocks are not supported yet.

Are there any alternative approaches or workarounds?

John
  • 949
  • 1
  • 9
  • 20

1 Answers1

0

The short answer seems to be no.

pypugjs is not feature complete, and whilst translating pug templates to jinja rather DTL templates avoids some of the issues, some features such as relative file imports are still not possible.

I expect pypugjs would work well for small or simple templates that don't use features such as mixins that receive objects, and relative imports.

John
  • 949
  • 1
  • 9
  • 20