0 votes
by (8.9k points)

This really looks like it ought to work, but...  frown

::Passage
<<set $nationality to "USA">>
His office is on the top floor, so you'll need to take the <<lift>>.
::Widget
<<widget "lift">>\
  <<if $nationality == "USA">>\
    <<= "elevator">>\
    <<elseif $nationality == "UK">>\
    <<= "lift">>\
  <</if>>\
<</widget>>

That outputs a space between the <<widget>> and the full stop/period at the end of the sentence, so it looks like this:

His office is on the top floor, so you'll need to take the elevator .

Can anybody see what I'm doing wrong?

 

 

1 Answer

+1 vote
by (68.6k points)
selected by
 
Best answer

Two things:

  1. The indention is causing the space, since you're using trailing line continuations.  Using leading line continuations instead will fix the issue, while still allowing you to use indention.
  2. Using the print macro to output static text is utterly pointless.

Try something like the following:

<<widget "lift">>
	\<<if $nationality is "USA">>
		\elevator
	\<<elseif $nationality is "UK">>
		\lift
	\<</if>>
\<</widget>>

 

by (8.9k points)

Thank you, Exile.  smileyyes

 
...