Skip to content

Latest commit

 

History

History

include-part-macro

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

The <<include-part>> macro

The <<include-part>> macro is a simple extension of SugarCube's built-in <<include>> which includes part of another passage instead of the whole thing.

Warning

Version 1 of this macro incorrectly ran SugarCube code present in the parts of the passage you were not including. Version 2 does not do this. If you are using version 1, you should upgrade.

Installation

Add the contents of include-part.js to your story Javascript.

Syntax

<<include-part "passage" "#target" [remove-container|boolean]>>

Include part of the passage given in the first argument into the current passage. The second argument is treated as a selector to identify which element to include. If the optional third argument is true then only the children of the selected element are included, if it is false (the default) then the selected element is also included.

Example

Passage1

<<include-part "passage2" "#target">>

Passage2

Some text.

Some other text.

<span id="target">Text to be included.</span>

Yet more text.

In this example, only the span with the id target gets included in Passage1. If the third argument was true (<<include-part "passage2" "#target" true>>) then only the text inside the span would be included in Passage1.