0

I have the following line in my Jade template:

img(src='#{similarArtist.image[0].#text}')

Do not ask me why Last.fm guys decided it was a good idea to use a name starting with hash in JSON document, but this is what I am dealing with.

It seems the 2nd hash sign trips up Jade. Maybe it expects two braces afterwards? I have tried prepending it with a backslash character (traditionally an escape operator) but that did not help.

So what can I do in this case? I really need to access that #text property.

Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175

2 Answers2

2

The # is not allowed in dot notation but you can use array notation for that. You can simply do:

img(src='#{similarArtist.image[0]['#text']}')
user568109
  • 47,225
  • 17
  • 99
  • 123
1

Not very beautiful solution but it works:

!= '<img src=' + similarArtist.image[0]['#text'] + '>'
Paul
  • 191
  • 5