Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33
@@ -42,10 +42,6 @@ func (*null) isNode() {}
|
||||
// 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
|
||||
// an independent pick.
|
||||
//
|
||||
// What `template.compileFormat` fills is final only once `linkTemplateRefs` has
|
||||
// run: where the format holds a reference, that binds it and compiles the format
|
||||
// again.
|
||||
type template struct {
|
||||
// Filled by `compileString`, `compileTemplate` and `table.compileWhole`:
|
||||
format string
|
||||
@@ -211,12 +207,20 @@ func compileString(s string) (node, error) {
|
||||
return nil, err
|
||||
}
|
||||
t := &template{format: s, repeat: 1, fromString: true}
|
||||
if err := t.compileFormat(); err != nil {
|
||||
if err := t.compileUnbound(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// compileUnbound compiles a format holding no reference; `linkTemplateRefs` compiles the rest.
|
||||
func (t *template) compileUnbound() error {
|
||||
if len(refTokens(t.format)) > 0 {
|
||||
return nil
|
||||
}
|
||||
return t.compileFormat()
|
||||
}
|
||||
|
||||
// compileFormat compiles the format into ops, and applies the fences that need the
|
||||
// compiled reads.
|
||||
func (t *template) compileFormat() error {
|
||||
@@ -335,7 +339,7 @@ func compileTemplate(m map[string]any, pos position) (node, error) {
|
||||
return nil, err
|
||||
}
|
||||
t := &template{format: o.format, fields: fields, repeat: o.repeat, separator: o.separator, datatype: o.datatype, drawGroup: o.group, record: fieldPos == inColumn}
|
||||
if err := t.compileFormat(); err != nil {
|
||||
if err := t.compileUnbound(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
|
||||
@@ -335,7 +335,7 @@ func (t *table) compileWhole(format string) error {
|
||||
}
|
||||
t.format = &template{format: format, fields: t.fields, repeat: 1, record: true, table: t}
|
||||
t.whole = &row{t}
|
||||
return t.format.compileFormat()
|
||||
return t.format.compileUnbound()
|
||||
}
|
||||
|
||||
// setTablePaths gives every table the path a selector on it is written at, before a
|
||||
|
||||
@@ -19,8 +19,6 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency.
|
||||
|
||||
This round, in order:
|
||||
|
||||
- Compile a template's format once: `compileFormat` runs again from `linkTemplateRefs`,
|
||||
so `ops`, `bound` and `held` are provisional until linking and its fences run twice.
|
||||
- Parse a format once and have the fences read `t.ops`: `eachToken` rescans the format
|
||||
in `fieldTokens`, `operandTokens`, `boundReaders`, `renderEdges`, `loneRef`,
|
||||
`operandReader`, `checkNoRepeatedRead` and `compileOps`, and function-versus-field is
|
||||
|
||||
Reference in New Issue
Block a user