3

Hello guys I am trying to inject a value inside a pug html attribute. I can not seem to find any documentation on how to do this. Here's my code

input(type='hidden', name='country', value='#{val.snippet.id.videoId}')

as you can imagine val.snippet.id.videoId is just a javascript variable I am passing from my server side. So I want to set the value attribute to that variable. Would really appreciate if someone points me to the right direction.

Shadid
  • 4,133
  • 9
  • 30
  • 53

2 Answers2

4

Wouldn't something like this work?

input(type='hidden', name='country', value=val.snippet.id.videoId)

As far as I remember you don't need to interpolate variables in attributes, just use them after =.

alvvi
  • 86
  • 1
  • 3
3

There's no need to interpolate (in attributes) since Pug 0.1.0 (Jade 2.x) as well as I know.

So, your solution is just:

input(type='hidden', name='country', value=val.snippet.id.videoId)
impregnable fiend
  • 289
  • 1
  • 5
  • 16