javascriptpugpugjs

How to inject a value inside a string in pug


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.


Solution

  • 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 =.