Yes, exactly as @omgninjas pointed out, it is called interpolation and preceded by # in Pug.
However you can't always use it (eg. inside a string). Here are some examples:
sensor
is a variable passed by the controller to the view.
- Normal interpolation. Works as expected:
<div id=#{sensor} style="width:90%;height:250px;"></div>
- Inside a string with Template Literals (don't use these with user supplied values!):
img(src=`/images/${sensor}.png`, style="width:20%")
- Inside a string used to denote a function call. Note that you cannot use the ` symbol (back tick aka grave accent used in template literals) with function calls because you would have to ecompass the entire function call . This results in a string which is not going to be executed. You need to use string concatenation.
body(onload="initTemp('"+ sensor +"')")
Here is the official documentation for Pug interpolation:
https://pugjs.org/language/interpolation.html
Hope this helps. Corrections and suggestions always welcome!
myVar
is a string, and part of that string is"${date}"
? And if so, are you asking how to replace that? (if so, then you need to go and research "javascript replace in string" – Selfstarter