Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Sugarcube] Whitespace problems

I'm trying to write a few custom widgets, and some of them have logic in them. In order to better visualize my logic, I set it up as if I were coding. For example, this is my first widget, designed to display the time:
<<widget "displayTime">>
<<if $args[0]>>
    <<if $time % 12 == 0>>
    	<<print "12">>
    <<else>>
    	<<print $time % 12>>
    <</if>
    <<print ":00 ">>
    <<if $time >= 12>>
    	<<print "PM">>
    <<else>>
    	<<print "AM">>
    <</if>>
<<else>>
    <<print "ERROR: no time given!">>
<</if>>
<</widget>>

The problem is that all those tabs and newlines are showing up when I use the widget. Is there a way to tell Sugarcube to ignore whitespace, and only care about what I have in the <<print>> tags?

Side note: if there's a better way to display the time, I'd love to hear about it. But I still want to know if there's an answer to my whitespace question, since I'd like to format my widgets this way if possible.

Comments

  • I just discovered the <<nobr>> tag, which seems to do what I want. Interestingly, the <<silently>> tag didn't work. Consider this question self-answered!
  • I can't seem to find the option to set this question to answered. I don't come on these forums very often. :P
  • As well as the <<nobr>> macro there is also the nobr passage tag.

    The <<silently>> macro is for situations where there is no output, and your code has a number of <<print>> macros in it.
  • Ah that makes sense. Thank you!
Sign In or Register to comment.