Skip to main content

Module template

Module template 

Source
Expand description

A template’s input marks and its spin-out (.tbrep). A template (.tbrep): a seed whose MARKED expressions are the user’s inputs. Inserting one never places the template: it asks for a new name and the input values, spins out a unique normal part with those values baked into its expressions, and places that.

The marks live in the template document as the top-level templateInputs block — one entry per input expression, with an optional label, limits or fixed list of choices. The spun-out copy KEEPS its expressions (it is an ordinary part the user can keep tweaking) and records where it came from in templateSource: the template’s file name and a content hash, for traceability only. Nothing links back; changing the template never touches a copy.

Structs§

TemplateInput
One marked input: an expression the user sets when inserting.
TemplateSource
What a spun-out copy records about its template.

Constants§

TEMPLATE_INPUTS_KEY
The document key the input marks are stored under.
TEMPLATE_SOURCE_KEY
The document key a spun-out copy records its template under.

Functions§

apply_inputs
Replace the engine document’s input marks as a USER edit (one undo step; coalesce groups a typing run). An empty list removes the block.
assignments
The name = rhs assignments of an expressions source, in order.
default_value
The template’s own value for name (its defining expression’s source), what the insert prompt starts the field from.
engine_inputs
The inputs the engine’s document marks. One map lookup and a small parse.
inputs_of
The inputs a template document marks (empty when none, or unreadable).
name_problem
Why name cannot be the spun-out part’s name, if it cannot: the same file name rules as a family member’s part number.
spin_out
The specialised copy of template (file template_file) with values (input name -> source text) baked into its expressions: a normal part that keeps its expressions, drops the input marks and the class, and records its template. Every value is checked first; the first problem is the error.
template_hash
A content hash of the whole template document less the view state it reopens in.
template_source
The copy’s record of its template, if the document is a spun-out copy.
value_problem
Why text is not an acceptable value for input, if it is not: it must evaluate (against the template’s own expressions, so width * 2 works) to a finite number inside the limits, and be one of the choices when there are choices.