"Passage Events": Snowman (v2.0.0)


Snowman triggers different events as they happen to passages.

In this example, a header and footer is created by listening for the 'sm.passage.shown' event with a jQuery event handle and then prepending the content of the passage "Header" and appending the content of the passage "Footer" to the current passage after it has been initially rendered.

Live Example

Download: Live Example

Twee Code

:: StoryTitle
Snowman 2: Passage Events

:: UserScript[script]
    Prepend the content of the passage "Header" to every passage.
        Append the content of the passage "Footer" to every passage.
$(window).on('sm.passage.shown', function (eventObject, passageObject) {
        var headerContent = window.story.render("Header");
        var currentContent = passageObject.passage.render();
        var footerContent = window.story.render("Footer");

        $('tw-passage').html(headerContent + currentContent + footerContent);

:: Start
<p>[[Another Passage]]</p>

:: Another Passage
[[Back to beginning->Start]]

:: Header
This is the header!

:: Footer
This is the footer!

Download: Twee Code

See Also

Headers and Footers

results matching ""

    No results matching ""