Group the template fields under the pass that fills each
This commit is contained in:
@@ -42,33 +42,45 @@ func (*null) isNode() {}
|
|||||||
// JSON string is a template with no fields. repeat (default 1) renders that format
|
// JSON string is a template with no fields. repeat (default 1) renders that format
|
||||||
// that many times and joins the results with separator (default ""), each render
|
// that many times and joins the results with separator (default ""), each render
|
||||||
// an independent pick.
|
// an independent pick.
|
||||||
|
//
|
||||||
|
// The groups below are filled in order: compiling the JSON writes the first and
|
||||||
|
// calls compileFormat for the second, then the reference link writes the third and
|
||||||
|
// calls compileFormat a second time, since a reference is a field the format reads
|
||||||
|
// and the first compile ran before any was bound.
|
||||||
type template struct {
|
type template struct {
|
||||||
format string
|
// Filled by `compileString`, `compileTemplate`, `table.compileFormat` and
|
||||||
fields map[string]node
|
// `checkCells`, from what the JSON says:
|
||||||
repeat int
|
format string
|
||||||
separator string
|
fields map[string]node
|
||||||
datatype DataType
|
repeat int
|
||||||
ops []op // format compiled once (see compileOps); what expand walks
|
separator string
|
||||||
grow int // minimum output size, to size the render buffer
|
datatype DataType
|
||||||
fixed bool // no op varies, so every render is lit
|
drawGroup string // the draw group it draws in, as written; "" keeps its caller's
|
||||||
lit string // the whole output when fixed
|
fromString bool // written as a JSON string rather than an object
|
||||||
refs map[string]refBinding // each reference the format reads -> what it is bound to
|
record bool // compiled at the top without a repeat, so its fields are record columns
|
||||||
|
table *table // the table whose format this is, whose columns are the fields
|
||||||
|
cellOf *table // the table whose cell this is
|
||||||
|
cellRow int // the row the cell sits in
|
||||||
|
|
||||||
|
// Filled by `template.compileFormat`, from the format over the fields above:
|
||||||
|
ops []op // what expand walks
|
||||||
|
grow int // minimum output size, to size the render buffer
|
||||||
|
fixed bool // no op varies, so every render is lit
|
||||||
|
lit string // the whole output when fixed
|
||||||
// bound maps each field the format addresses by dotted path to one path token
|
// bound maps each field the format addresses by dotted path to one path token
|
||||||
// reading it, which is the half of an overlap the fences name. nil when the
|
// reading it, which is the half of an overlap the fences name. nil when the
|
||||||
// format takes no path.
|
// format takes no path.
|
||||||
bound map[string]string
|
bound map[string]string
|
||||||
// held is every name drawn once per expansion: the bound levels above, plus the
|
// held is every name drawn once per expansion: the bound levels above, plus the
|
||||||
// siblings a {calc()} reads. nil when the format holds nothing (see expand).
|
// siblings a {calc()} reads. nil when the format holds nothing (see expand).
|
||||||
held map[string]bool
|
held map[string]bool
|
||||||
heldLocal bool // some held name is kept by the expansion itself, so expand makes its draws
|
heldLocal bool // some held name is kept by the expansion itself, so expand makes its draws
|
||||||
fromString bool // written as a JSON string rather than an object
|
|
||||||
readsColumn *columnRead // set when the format is one reference alone reading a record's column
|
// Filled by `linkRefs`, or `linkNodeRefs` for an inline template, from the
|
||||||
record bool // compiled at the top without a repeat, so its fields are record columns
|
// assembled tree, which also add each bound reference to fields above:
|
||||||
table *table // the table whose format this is, whose columns are the fields
|
refs map[string]refBinding // each reference the format reads -> what it is bound to
|
||||||
cellOf *table // the table whose cell this is
|
readsColumn *columnRead // set when the format is one reference alone reading a record's column
|
||||||
cellRow int // the row the cell sits in
|
drawGroupKey string // its draw group keyed by its category: what a render reads its reference paths under
|
||||||
drawGroup string // the draw group it draws in, as written; "" keeps its caller's
|
|
||||||
drawGroupKey string // its draw group keyed by its category once linked: what a render reads its reference paths under
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*template) isNode() {}
|
func (*template) isNode() {}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ name says whether a unit runs at `New` or at `Fake`.
|
|||||||
|
|
||||||
This round, in order:
|
This round, in order:
|
||||||
|
|
||||||
- Say on the `template` struct which pass fills which field, and that `compileFormat`
|
|
||||||
runs a second time once `linkTemplateRefs` binds the references: nine of its fields
|
|
||||||
are written by four other files, and the order lives only in `loadData`'s body.
|
|
||||||
- State on `rowSet` that it simulates `(*draws).pin` and `rowOf`, and prove the two
|
- State on `rowSet` that it simulates `(*draws).pin` and `rowOf`, and prove the two
|
||||||
agree with a test: the load-time walk reimplements the render-time pinning, nothing
|
agree with a test: the load-time walk reimplements the render-time pinning, nothing
|
||||||
catches them drifting, and the failure is data that loads and then renders a family
|
catches them drifting, and the failure is data that loads and then renders a family
|
||||||
|
|||||||
Reference in New Issue
Block a user