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
The <<silently>> macro is for situations where there is no output, and your code has a number of <<print>> macros in it.