Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use mixin inline in Jade

Tags:

html

pug

I am trying to use a mixin in the middle of a line of jade like this...

p some paragraph text !{ 'this'+'works' } but !{ +myMixin() } breaks it!

But it doesn't work. I can't figure out how to reference a mixin in the middle of a line of jade. Is it possible?

like image 240
Billy Moon Avatar asked Nov 04 '13 12:11

Billy Moon


2 Answers

You need special way to use jade mixins inline:

p.
  Hello I'm using #[+jadeMixin(param)] inline.
like image 62
Ejaz Karim Avatar answered Oct 26 '22 23:10

Ejaz Karim


It's not possible to put a mixin in a sentence like that. What you can do is include blocks inside the mixin and use pikes | for plain text.

mixin myMixin()
  strong
   block

p This is a sentence 
  +myMixin()
    | with bold text
  |  and this is the rest of it

Which will render:

<p>This is a sentence <strong>with bold text</strong> and this is the rest of it</p>
like image 23
Craig Avatar answered Oct 27 '22 00:10

Craig