2

I want to print an include as a result of a mixin, but jade wants to parse the include when it first reads the mixin.

mixin myHeader(name)
  div#{name} 
    h1 #{name}
      include #{name}


!!! html
  html
    head
    body
      +myHeader(#home)
      +myHeader(#schedule)
      +myHeader(#map)
      +myHeader(#lecturers)

I think the error is telling me jade can't find #{name} to include in the mixin.

ENOENT, no such file or directory '#{name}.jade'

Lochlan
  • 27
  • 1
  • 6

2 Answers2

7

Jade does not support variables in includes. A workaround is demonstrated in this stackoverflow question

Community
  • 1
  • 1
saintedlama
  • 6,838
  • 1
  • 28
  • 46
0

Maybe you can use mixins made in different files instead

like

// popups.pug
mixin temperature()
  h3 temperature

Included in another file worked fine for me

//modal-content.pug
include popups
mixin modal-content-popup(component)

  .modal-content
    .modal-content__settings
      +#{component}()
    .modal-content__buttons
      button.modal-content__button.modal-content__button--apply Применить
      button.modal-content__button.modal-content__button--close Закрыть

+modal-content-popup('temperature')
Tomas
  • 471
  • 7
  • 10