Adding links and macros within a pop-up

Twine Version:2.12.0.0
SugarCube 2.37.3

I am trying to create pop-up menu for using items during combat. Thus far I have learned that using dialogue API I can add text. It seems to only accept strings. Is there a way I can add things like <> macros and links within the pop-up?

Here is my relevant code:

[[Attack|Fairy Combat][$actiontype=“attack”]]<br><br>
[[Dodge|Fairy Combat][$actiontype=“dodge”]]<br><br>

<<link “Items”>> 
 <<script>>  
  Dialog.create(“Combat Items”);  
  Dialog.wiki()			  
  Dialog.open(); 
 <</script>>
<</link>>

What I wanted to do looked like this:

Dialog.wiki(<<if $items_consumable.Milk>0>>
 [[Dodge|Fairy Combat][$actiontype="item" $itemtype="milk"]]
 <</if>>)

Sorry this is probably something simple but I am thoroughly stuck. Side note: I have line breaks switched from automatic to manual and that might make my code look weird but it is easier to me.

There are a number of issue with your Dialog.wiki() method call:

1: When assigning a value to multiple variables within the Setter section of a Markup based Link with Setter, there should be a semi-column ; between each variable assignment. Because each of those assignments are an individual statement, and JavaScript (generally) requires a semi-column between statements.

[[Dodge|Fairy Combat][$actiontype="item"; $itemtype="milk"]]

2: The JavaScript based Dialog.wiki() method expects to be passed a String value, that contains the TwineScript / Markup it is meant to process into HTML output.

Dialog.wiki('Hello there <<= $mc.name >>');

You could rewrite your original Dialog.wiki() call as…

Dialog.wiki('<<if $items_consumable.Milk > 0>>[[Dodge|Fairy Combat][$actiontype="item"; $itemtype="milk"]]<</if>>');

…however, seeing as there is no output if the conditional expression is false it would make more sense to do the conditional expression evaluation outside the method call, and to only call that method if the conditional expression is true.

if (State.variables.items_consumable.Milk > 0) {
    Dialog.wiki('[[Dodge|Fairy Combat][$actiontype="item"; $itemtype="milk"]]');
}

3: Generally if a Dialog is going to contain the output from the processing of multiple pieces of TwineScript / Markup, it is better to place all that TwineScript / Markup inside a “child” type Passage and then use the Dialog.wikiPassage() method instead of Dialog.wiki() to display the out put of that Passage inside the Dialog.

note: the following example is Twee Notation based, as it contains multiple Passage definitions.

:: Passage with the Dialog Link
Blah Blah Blah 

<<link “Items”>> 
    <<script>>  
        Dialog.create(“Combat Items”);  
        Dialog.wikiPassage('Combat Items');
        Dialog.open(); 
    <</script>>
<</link>>

:: Combat Items
<<if $items_consumable.Milk > 0>>
    [[Dodge|Fairy Combat][$actiontype="item"; $itemtype="milk"]]
<</if>>
...and all the other content this Dialog needs to show....

Thank you very much Greyelf! Your answer was carefully thought out and incredibly educational. My code is working and I can use the same principles I learned on spells too.

Thanks again Greyelf!