barrylachapelle
barrylachapelle

Reputation: 987

Passing Node variables from Jade to included html?

I am trying to access jade vars from an included html file in jade. For example...

Route:

router.get('/htmltest', function(req, res, next) {
  res.render('htmltest', { title: 'HTML TEST' });
});

Jade:

block content
    include htmltest.html

htmltest.html:

<p>This is included html #{title}</p>

The title doesn't display in html. I guess I have a scoping issue. Any thoughts on how I could achieve this?

Upvotes: 0

Views: 46

Answers (1)

Matt Greenberg
Matt Greenberg

Reputation: 2330

Every line in jade that starts with an open bracket < is considered a single string of text. You need to change the htmltest.html file to...

p This is included html #{title}

Upvotes: 1

Related Questions