Partials

Splicing a .part.chalk file of your own into an internote with @include, and what a partial may hold.

#Including a file of your own

@include splices a partial — a file of Chalk ending .part.chalk — into the document where the directive is written. On the platform a partial is one of the internote's attachments. Here two partials hold a course's notation and its opening scene:

@let(rate: \lambda; course: STAT2001)

@define:recap{
    note{
        {{body}}
    }
}(
    body: !inline(content: all)
)
notation.part.chalk
scene{
    ## Where we are

    This is week {{week}} of {{course}}.
}
opening.part.chalk
@include:notation.part.chalk

@let(week: 3)

@include:opening.part.chalk

scene{
    recap{The arrival rate is ${{rate}}$.}
}
The internote

The result is the document as if both files had been typed in place: the opening scene reads This is week 3 of STAT2001., and recap is a template from the first partial, used in the internote.

@include(src: …) is the named form, needed for a name with a space in it. The name ends .chalk — `notes.txt` has extension `txt`, but only chalk are permitted — and a name that matches no attachment is included file not found: `nope.part.chalk`. A relative path is read from the including file's folder, so an internote synced from a git repository can include ../shared/notation.part.chalk.

#What a partial may hold

A partial holds whatever is legal where it lands. Scenes belong at the top of the document, so a partial of scenes included inside a scene is refused at its first scene, and the error is reported in the partial, at opening.part.chalk:1:

scene{
    @include:opening.part.chalk
}

[content-policy]node `scene` is not allowed here (allowed: paragraph, h1, h2, h3, h4, list, equation, definition, example, note, task, internote, divider, step)

  • Declarations — @let, @define, @preset, @data — register at the include site and are visible after it, as if written there.
  • A partial reads the constants declared above the @include. Moving @let(week: 3) below the second include above gives `{{week}}`: undefined constant `week`, at opening.part.chalk:4.
  • A partial carries no header: the document header must be the first node of the document.
  • @include takes no body — @include: takes attributes only — so a partial has no parameters. Source that changes from one use to the next is a template: Modularity.
  • Every id in a partial is declared each time it is included, so a partial with ids included twice is a duplicate id error.
  • A partial may include another, but not itself, directly or through another: circular include.

Last updated