Snowman 1.3: Using Underscore.js
While Snowman can seem initally frustrating to users coming from Harlowe or SugarCube story formats, it acutally has a very rich set of functionality just below the surface with its inclusion of Underscore.js, a JavaScript library enabling usage of a large number of utility functions and advanced templating abilities.
[[Templates]]
Underscore.js borrows heavily from embedded Ruby (ERB) formatting through using less-than and greater-than signs paired with the percentage sign to mark template usage.
For example, the name of this passage is: <%= window.passage.name %>
However, while different, it also allows JavaScript code and conditional statements to be easily tested and content changed, like with hooks in Harlowe, based on existing values.
[[Conditional Content]]
In fact, we can skip using the SCRIPT element completely to use Underscore's template system instead. (Think of it as using macros in Harlowe and SugarCube -- it's the same 'language' but a different dialect!)
<% var testBoolean = true; %>
<% if ( testBoolean ){ %>
<h2>Show me!</h2>
<% } else { %>
<h2>Never show me!</h2>
<% } %>
[[Snowman Markdown]][
While it may not seem as obvious, Snowman also come with its own form of markdown, like with Harlowe and SugarCube, along with and because of its use of Underscore.
]{#redText}