0
votes

at my backend I have such object which I am rendering:

  objectToRender =
    url: getUrl
    pid: pid
    meta: ['<meta name="one" code="272387238">', '<meta name="two" code="272387238">']
    urlEncoded: encodeGetUrl

  res.render 'index.jade', {objectToRender}

I need to take all meta tags and pass them to index.jade:

each val in #{objectToRender.meta}
   meta = val

But everything is crashing down

What can I do here?

my error is :

SyntaxError: /opt/rrr/yyyy/views/index.jade:7 5|
link(rel='stylesheet', type='text/css', href='build/css/app.css')
6| script(src='build/js/plugin_manager.js')

7| each val in #{objectToRender.meta} 8| meta = !{val} 9| body 10| strong#pid product id received:

{objectToRender.pid}

Unexpected token ILLEGAL at Function (:null:null)

1
What is the crash message? Also you're missing parentheses in your res.render statement res.render('index.jade', {objectToRender}) - Bidhan
@BidhanA in coffeescript u dont need them - Jesus_Maria
Oh, I didn't know you were using coffeescript. But anyway my question still stands, what is the crash message? - Bidhan
@BidhanA updated question - Jesus_Maria

1 Answers

1
votes

You have incorrect syntax for each..in. Interpolation doesn't happen inside it. Also as you have html tags inside the object, you need to unescape the value.

Try this:

each val in objectToRender.meta
 | !{val}