Skip to content

"Render Passage to Element": Snowman (v2.0.0)#


In Snowman, the function renderToSelector() renders the contents of a passage into an element based on its jQuery selector.

The event "sm.passage.shown" is used in this example to guarantee that the passage has been rendered before acting. Calling the function renderToSelector() inside the jQuery event listener then renders another passage into an existing element.



Twee Code#

:: StoryTitle
Snowman: Render to Element

:: Start
<div id="hudID"></div>
$(document).one('sm.passage.shown', function (ev) {
  // Render the passage named HUD into the element with id of "hudID"
    renderToSelector("#hudID", "HUD");

:: HUD
<h1>This is the HUD!</h1>

Twee Download