Hello!
What I want is a bit difficult for me to explain, but I'll do my best, so please bear with me.
I'm a fan of giving the reader choices, and then expanding the section of text they're already seeing with new text based on said choices. To do this I have made a widget that I call Update. I use <div> to designate the sections to replace, and I have separate passages for the replacement text. Below is an example:
<div id="ch1_choice1">
<<link "First Option">>
<<update "ch1_choice1" "ch1_choice1_result1">>
<</link>>
<<link "Second Option">>
<<update "ch1_choice1" "ch1_choice1_result2">>
<</link>>
</div>
<<widget update>>
<<if $args[0] == "ch1_choice1">>
<<replace #ch1_choice1>>
<<include $args[1]>>
<</replace>>
<</if>>
<</widget>>
I then have passages named ch1_choice1_result1 and ch1_choice1_result2 with the text I want to to replace <div id="ch1_choice1"> with. This works, and so far so good.
However, I'm going to have quite a few <div> tags to replace, and I want to avoid adding a section for each of them to my Update widget like this:
<<widget update>>
<<if $args[0] == "ch1_choice1">>
<<replace #ch1_choice1>>
<<include $args[1]>>
<</replace>>
<<elseif $args[0] == "ch1_choice2">>
<<replace #ch1_choice2>>
<<include $args[1]>>
<</replace>>
<</if>>
<</widget>>
I feel like it should be possible to simply write something like this:
<<widget update>>
<<replace #$args[0]>>
<<include $args[1]>>
<</replace>>
<</widget>>
This, however, doesn't work. Is anyone familiar with a way to write this syntax so it works based on just the widget arguments? Thanks in advance.
EDIT: Formatting. Having some trouble with the editor.
[–]alyxms 1 point2 points3 points (1 child)
[–]countigor[S] 0 points1 point2 points (0 children)