www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - vibe.d diet - is there a way to use a D variable inside the

reply Chris Bare <chris bareflix.com> writes:
I'm trying to generate a list of buttons and insert the value 
programmatically.
Here's what I've tried:
		- foreach (i; ["Prev", "Replay", "Next"])

that does not compile.
if instead I use:



Is there a way to double escape the variable, or is substitution 
just not supported there?
Dec 29 2020
parent reply Chris Bare <chris bareflix.com> writes:
On Tuesday, 29 December 2020 at 20:16:40 UTC, Chris Bare wrote:
 I'm trying to generate a list of buttons and insert the value 
 programmatically.
 Here's what I've tried:
 		- foreach (i; ["Prev", "Replay", "Next"])

 that does not compile.
 if instead I use:



 Is there a way to double escape the variable, or is 
 substitution just not supported there?
One minute after I sent this I tried: input(type="button",value=i) and that works.
Dec 29 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 12/29/20 3:22 PM, Chris Bare wrote:
 On Tuesday, 29 December 2020 at 20:16:40 UTC, Chris Bare wrote:
 I'm trying to generate a list of buttons and insert the value 
 programmatically.
 Here's what I've tried:
         - foreach (i; ["Prev", "Replay", "Next"])

 that does not compile.
 if instead I use:



 Is there a way to double escape the variable, or is substitution just 
 not supported there?
One minute after I sent this I tried: input(type="button",value=i) and that works.
Yes. Just one thing to be aware of, if i is a boolean, then the behavior is to include "value" or not include "value" in the element. In other words: sometag(foo=true) => <sometag foo="foo"> (or something like that) sometag(foo=false) => <sometag > The only other annoying thing is that you can't use interpolations for classes directly using pug syntax, you have to use class attributes inside the parentheses. -Steve
Dec 31 2020