retold 4.0.3 → 4.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/launch.json +29 -0
- package/.claude/settings.local.json +85 -2
- package/CLAUDE.md +4 -2
- package/README.md +24 -2
- package/Retold-Modules-Manifest.json +576 -0
- package/docs/README.md +7 -1
- package/docs/{cover.md → _cover.md} +1 -1
- package/docs/_sidebar.md +30 -2
- package/docs/architecture/architecture.md +7 -4
- package/docs/architecture/dependencies/_generate-graph.js +186 -0
- package/docs/architecture/dependencies/_generate-svg.js +364 -0
- package/docs/architecture/dependencies/in-ecosystem-dependency-graph-generation.md +97 -0
- package/docs/architecture/dependencies/in-ecosystem-dependency-graph.json +3168 -0
- package/docs/architecture/dependencies/in-ecosystem-dependency-graph.md +221 -0
- package/docs/architecture/dependencies/in-ecosystem-dependency-graph.svg +664 -0
- package/docs/architecture/documentation-style-guide.md +65 -0
- package/docs/architecture/example-app-style-guide.md +154 -0
- package/docs/architecture/modules.md +19 -8
- package/docs/architecture/templating/data-access.md +196 -0
- package/docs/architecture/templating/data-formatting.md +350 -0
- package/docs/architecture/templating/data-generation.md +72 -0
- package/docs/architecture/templating/debugging.md +181 -0
- package/docs/architecture/templating/entity.md +99 -0
- package/docs/architecture/templating/iteration.md +170 -0
- package/docs/architecture/templating/jellyfish-deep-dive.md +271 -0
- package/docs/architecture/templating/jellyfish-templates.md +476 -0
- package/docs/architecture/templating/logic.md +185 -0
- package/docs/architecture/templating/ref-breakpoint.md +38 -0
- package/docs/architecture/templating/ref-data.md +51 -0
- package/docs/architecture/templating/ref-dateonlyformat.md +43 -0
- package/docs/architecture/templating/ref-dateonlyymd.md +39 -0
- package/docs/architecture/templating/ref-datetimeformat.md +59 -0
- package/docs/architecture/templating/ref-datetimeymd.md +44 -0
- package/docs/architecture/templating/ref-dejs.md +42 -0
- package/docs/architecture/templating/ref-digits.md +36 -0
- package/docs/architecture/templating/ref-dj.md +50 -0
- package/docs/architecture/templating/ref-dollars.md +36 -0
- package/docs/architecture/templating/ref-dt.md +38 -0
- package/docs/architecture/templating/ref-dvbk.md +46 -0
- package/docs/architecture/templating/ref-dwaf.md +45 -0
- package/docs/architecture/templating/ref-dwtf.md +45 -0
- package/docs/architecture/templating/ref-entity.md +47 -0
- package/docs/architecture/templating/ref-hce.md +29 -0
- package/docs/architecture/templating/ref-hcs.md +38 -0
- package/docs/architecture/templating/ref-join.md +45 -0
- package/docs/architecture/templating/ref-joinunique.md +34 -0
- package/docs/architecture/templating/ref-ls.md +37 -0
- package/docs/architecture/templating/ref-lv.md +38 -0
- package/docs/architecture/templating/ref-lvt.md +33 -0
- package/docs/architecture/templating/ref-ne.md +40 -0
- package/docs/architecture/templating/ref-pascalcaseidentifier.md +41 -0
- package/docs/architecture/templating/ref-pict.md +42 -0
- package/docs/architecture/templating/ref-pluckjoinunique.md +39 -0
- package/docs/architecture/templating/ref-rn.md +35 -0
- package/docs/architecture/templating/ref-rns.md +35 -0
- package/docs/architecture/templating/ref-sbr.md +36 -0
- package/docs/architecture/templating/ref-solve.md +46 -0
- package/docs/architecture/templating/ref-tbda.md +41 -0
- package/docs/architecture/templating/ref-tbr.md +43 -0
- package/docs/architecture/templating/ref-tbt.md +46 -0
- package/docs/architecture/templating/ref-template.md +40 -0
- package/docs/architecture/templating/ref-tfa.md +32 -0
- package/docs/architecture/templating/ref-tfm.md +43 -0
- package/docs/architecture/templating/ref-tif.md +45 -0
- package/docs/architecture/templating/ref-tifabs.md +41 -0
- package/docs/architecture/templating/ref-ts.md +41 -0
- package/docs/architecture/templating/ref-tsfm.md +42 -0
- package/docs/architecture/templating/ref-tswp.md +45 -0
- package/docs/architecture/templating/ref-tvs.md +48 -0
- package/docs/architecture/templating/ref-view.md +40 -0
- package/docs/architecture/templating/ref-vrs.md +39 -0
- package/docs/architecture/templating/solvers.md +153 -0
- package/docs/architecture/templating/template-composition.md +196 -0
- package/docs/architecture/templating/template-expressions.md +217 -0
- package/docs/architecture/templating/views.md +154 -0
- package/docs/contributing.md +50 -0
- package/docs/examples/todolist/todo-list.md +1 -1
- package/docs/modules/apps.md +26 -0
- package/docs/modules/orator.md +0 -7
- package/docs/modules/pict.md +18 -0
- package/docs/modules/utility.md +23 -1
- package/docs/retold-catalog.json +937 -126
- package/docs/retold-keyword-index.json +195296 -116062
- package/docs/testing.md +122 -0
- package/modules/CLAUDE.md +1 -0
- package/modules/Checkout.sh +1 -0
- package/modules/Diff.sh +86 -0
- package/modules/Include-Retold-Module-List.sh +5 -3
- package/modules/Status.sh +1 -0
- package/modules/Update.sh +1 -0
- package/modules/apps/Apps.md +1 -0
- package/modules/utility/Utility.md +1 -0
- package/package.json +12 -11
- package/source/retold-manager/package.json +23 -0
- package/source/retold-manager/retold-manager.js +65 -0
- package/source/retold-manager/source/Retold-Manager-App.js +1532 -0
- package/source/retold-manager/source/Retold-Manager-ModuleCatalog.js +75 -0
- package/source/retold-manager/source/Retold-Manager-ProcessRunner.js +706 -0
- package/source/retold-manager/source/views/PictView-TUI-Checkout.js +45 -0
- package/source/retold-manager/source/views/PictView-TUI-Header.js +41 -0
- package/source/retold-manager/source/views/PictView-TUI-Layout.js +53 -0
- package/source/retold-manager/source/views/PictView-TUI-Status.js +45 -0
- package/source/retold-manager/source/views/PictView-TUI-StatusBar.js +41 -0
- package/source/retold-manager/source/views/PictView-TUI-Update.js +45 -0
- package/docs/retold-building-documentation.md +0 -33
- package/examples/quickstart/layer1/package-lock.json +0 -344
- package/examples/quickstart/layer2/package-lock.json +0 -4468
- package/examples/quickstart/layer3/package-lock.json +0 -1936
- package/examples/quickstart/layer4/package-lock.json +0 -13206
- package/examples/quickstart/layer5/package-lock.json +0 -345
- package/examples/todo-list/cli-client/package-lock.json +0 -418
- package/examples/todo-list/console-client/package-lock.json +0 -426
- package/examples/todo-list/server/package-lock.json +0 -6113
- package/examples/todo-list/web-client/package-lock.json +0 -12030
- package/modules/Retold-Modules.md +0 -24
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Reference: Template (T)
|
|
2
|
+
|
|
3
|
+
Renders a registered template by its hash.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~Template:HASH~}` `{~T:HASH~}` or `{~T:HASH:DATA_ADDRESS~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-Template.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~T:TEMPLATE_HASH~}
|
|
13
|
+
{~T:TEMPLATE_HASH:DATA_ADDRESS~}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
| Parameter | Required | Description |
|
|
19
|
+
|-----------|----------|-------------|
|
|
20
|
+
| TEMPLATE_HASH | Yes | Hash of a registered template |
|
|
21
|
+
| DATA_ADDRESS | No | Address to resolve and pass as Record |
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
_Pict.TemplateProvider.addTemplate('Badge',
|
|
27
|
+
'<span class="badge">{~D:Record.Label~}</span>');
|
|
28
|
+
|
|
29
|
+
_Pict.parseTemplate('{~T:Badge:AppData.User~}');
|
|
30
|
+
// Renders Badge with AppData.User as Record
|
|
31
|
+
|
|
32
|
+
_Pict.parseTemplate('{~T:Badge~}', { Label: 'Admin' });
|
|
33
|
+
// Renders Badge with the current Record
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Related
|
|
37
|
+
|
|
38
|
+
- [TBR](architecture/templating/ref-tbr.md) -- Template hash from data
|
|
39
|
+
- [TBDA](architecture/templating/ref-tbda.md) -- Template content from data
|
|
40
|
+
- [TS](architecture/templating/ref-ts.md) -- Render for each item in a collection
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Reference: TemplateFromAddress (TFA)
|
|
2
|
+
|
|
3
|
+
Reads template content from a data address and parses it. Identical to TBDA.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateFromAddress:ADDRESS~}` `{~TFA:ADDRESS~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateFromAddress.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TFA:ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| ADDRESS | Yes | Path to a string containing template content |
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
_Pict.parseTemplate('{~TFA:Record.Markup~}',
|
|
25
|
+
{ Markup: '<b>{~D:Record.Name~}</b>', Name: 'Alice' });
|
|
26
|
+
// '<b>Alice</b>'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Related
|
|
30
|
+
|
|
31
|
+
- [TBDA](architecture/templating/ref-tbda.md) -- Identical behavior
|
|
32
|
+
- [TBR](architecture/templating/ref-tbr.md) -- Resolve a template hash from data
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Reference: TemplateFromMap (TFM)
|
|
2
|
+
|
|
3
|
+
Looks up a key in a map, retrieves the entry, and renders a template with it as Record.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateFromMap:HASH:MAP:KEY~}` `{~TFM:HASH:MAP:KEY~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateFromMap.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TFM:TEMPLATE_HASH:MAP_ADDRESS:KEY_ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Hash of the template to render |
|
|
20
|
+
| MAP_ADDRESS | Yes | Address of the map/object |
|
|
21
|
+
| KEY_ADDRESS | Yes | Address containing the key to look up |
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
_Pict.AppData.Authors = {
|
|
27
|
+
'A-01': { Name: 'Frank Herbert', Born: 1920 },
|
|
28
|
+
'A-02': { Name: 'William Gibson', Born: 1948 }
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
_Pict.TemplateProvider.addTemplate('AuthorLabel',
|
|
32
|
+
'{~D:Record.Name~} (b. {~D:Record.Born~})');
|
|
33
|
+
|
|
34
|
+
_Pict.parseTemplate('{~TFM:AuthorLabel:AppData.Authors:Record.IDAuthor~}',
|
|
35
|
+
{ IDAuthor: 'A-01' });
|
|
36
|
+
// 'Frank Herbert (b. 1920)'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
- [T](architecture/templating/ref-template.md) -- Render with direct data
|
|
42
|
+
- [DVBK](architecture/templating/ref-dvbk.md) -- Simple value lookup by key
|
|
43
|
+
- [TSFM](architecture/templating/ref-tsfm.md) -- Iterate an array from a map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Reference: TemplateIf (TIf)
|
|
2
|
+
|
|
3
|
+
Compares two data-resolved values. Renders a template if the comparison is true.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateIf:HASH:DATA:CONDITION~}` `{~TIf:HASH:DATA:CONDITION~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/logic/Pict-Template-TemplateIf.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TIf:TEMPLATE_HASH:DATA_ADDRESS:LEFT^OPERATOR^RIGHT~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Template to render if true |
|
|
20
|
+
| DATA_ADDRESS | No | Data to pass as Record (can be empty) |
|
|
21
|
+
| LEFT | Yes | Address for left operand |
|
|
22
|
+
| OPERATOR | Yes | Comparison operator |
|
|
23
|
+
| RIGHT | Yes | Address for right operand |
|
|
24
|
+
|
|
25
|
+
## Operators
|
|
26
|
+
|
|
27
|
+
`==`, `===`, `!=`, `!==`, `>`, `>=`, `<`, `<=`, `TRUE`, `FALSE`, `LNGT` (length >), `LNLT` (length <)
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
_Pict.TemplateProvider.addTemplate('Match', '<span>Match!</span>');
|
|
33
|
+
|
|
34
|
+
_Pict.AppData = { Actual: 200, Expected: 200 };
|
|
35
|
+
_Pict.parseTemplate('{~TIf:Match::AppData.Actual^==^AppData.Expected~}');
|
|
36
|
+
// '<span>Match!</span>'
|
|
37
|
+
|
|
38
|
+
_Pict.parseTemplate('{~TIf:Match::AppData.Actual^>^AppData.Expected~}');
|
|
39
|
+
// '' (200 is not > 200)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Related
|
|
43
|
+
|
|
44
|
+
- [TIfAbs](architecture/templating/ref-tifabs.md) -- Compare against a literal value
|
|
45
|
+
- [NE](architecture/templating/ref-ne.md) -- Simple truthiness check
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Reference: TemplateIfAbsolute (TIfAbs)
|
|
2
|
+
|
|
3
|
+
Compares a data-resolved value against a literal. Renders a template if the comparison is true.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateIfAbsolute:HASH:DATA:CONDITION~}` `{~TIfAbs:HASH:DATA:CONDITION~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/logic/Pict-Template-TemplateIfAbsolute.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TIfAbs:TEMPLATE_HASH:DATA_ADDRESS:LEFT^OPERATOR^LITERAL~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Template to render if true |
|
|
20
|
+
| DATA_ADDRESS | No | Data to pass as Record (can be empty) |
|
|
21
|
+
| LEFT | Yes | Address for left operand |
|
|
22
|
+
| OPERATOR | Yes | Comparison operator (same as TIf) |
|
|
23
|
+
| LITERAL | Yes | A literal value (not resolved from data) |
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
_Pict.TemplateProvider.addTemplate('Admin', '<span>Admin</span>');
|
|
29
|
+
|
|
30
|
+
_Pict.AppData.User = { Role: 'admin' };
|
|
31
|
+
_Pict.parseTemplate('{~TIfAbs:Admin::AppData.User.Role^==^admin~}');
|
|
32
|
+
// '<span>Admin</span>'
|
|
33
|
+
|
|
34
|
+
_Pict.parseTemplate('{~TIfAbs:Admin::AppData.User.Role^==^guest~}');
|
|
35
|
+
// ''
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Related
|
|
39
|
+
|
|
40
|
+
- [TIf](architecture/templating/ref-tif.md) -- Compare two data addresses
|
|
41
|
+
- [NE](architecture/templating/ref-ne.md) -- Simple truthiness output
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Reference: TemplateSet (TS)
|
|
2
|
+
|
|
3
|
+
Renders a template once for each item in a collection. Each item becomes Record.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateSet:HASH:COLLECTION~}` `{~TS:HASH:COLLECTION~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateSet.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TS:TEMPLATE_HASH:COLLECTION_ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Hash of the template to render per item |
|
|
20
|
+
| COLLECTION_ADDRESS | Yes | Address of an array or object to iterate |
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
_Pict.TemplateProvider.addTemplate('Row',
|
|
26
|
+
'<tr><td>{~D:Record.Name~}</td></tr>');
|
|
27
|
+
|
|
28
|
+
_Pict.AppData.Users = [
|
|
29
|
+
{ Name: 'Alice' },
|
|
30
|
+
{ Name: 'Bob' }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
_Pict.parseTemplate('<table>{~TS:Row:AppData.Users~}</table>');
|
|
34
|
+
// '<table><tr><td>Alice</td></tr><tr><td>Bob</td></tr></table>'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Related
|
|
38
|
+
|
|
39
|
+
- [TSFM](architecture/templating/ref-tsfm.md) -- Iterate from a map lookup
|
|
40
|
+
- [TSWP](architecture/templating/ref-tswp.md) -- Iterate with payload
|
|
41
|
+
- [TVS](architecture/templating/ref-tvs.md) -- Iterate over values with key/index metadata
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Reference: TemplateSetFromMap (TSFM)
|
|
2
|
+
|
|
3
|
+
Looks up a key in a map to get an array, then renders a template for each item.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateSetFromMap:HASH:MAP:KEY~}` `{~TSFM:HASH:MAP:KEY~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateSetFromMap.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TSFM:TEMPLATE_HASH:MAP_ADDRESS:KEY_ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Hash of the template to render per item |
|
|
20
|
+
| MAP_ADDRESS | Yes | Address of a map whose values are arrays |
|
|
21
|
+
| KEY_ADDRESS | Yes | Address containing the key to look up |
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
_Pict.AppData.Teams = {
|
|
27
|
+
'Engineering': [{ Name: 'Alice' }, { Name: 'Bob' }],
|
|
28
|
+
'Design': [{ Name: 'Carol' }]
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
_Pict.TemplateProvider.addTemplate('Member', '<li>{~D:Record.Name~}</li>');
|
|
32
|
+
|
|
33
|
+
_Pict.parseTemplate(
|
|
34
|
+
'<ul>{~TSFM:Member:AppData.Teams:Record.Dept~}</ul>',
|
|
35
|
+
{ Dept: 'Engineering' });
|
|
36
|
+
// '<ul><li>Alice</li><li>Bob</li></ul>'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
- [TS](architecture/templating/ref-ts.md) -- Iterate over a direct collection
|
|
42
|
+
- [TFM](architecture/templating/ref-tfm.md) -- Single item from map (not iterated)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Reference: TemplateSetWithPayload (TSWP)
|
|
2
|
+
|
|
3
|
+
Renders a template for each item, wrapping each as `{ Data, Payload }`.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateSetWithPayload:HASH:COLLECTION:PAYLOAD~}` `{~TSWP:HASH:COLLECTION:PAYLOAD~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateSetWithPayload.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TSWP:TEMPLATE_HASH:COLLECTION_ADDRESS:PAYLOAD_ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Hash of the template to render per item |
|
|
20
|
+
| COLLECTION_ADDRESS | Yes | Address of an array to iterate |
|
|
21
|
+
| PAYLOAD_ADDRESS | Yes | Address of extra data included with each item |
|
|
22
|
+
|
|
23
|
+
## Behavior
|
|
24
|
+
|
|
25
|
+
Inside the rendered template, Record has two properties:
|
|
26
|
+
- `Record.Data` -- the current array item
|
|
27
|
+
- `Record.Payload` -- the resolved payload object
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
_Pict.TemplateProvider.addTemplate('Item',
|
|
33
|
+
'<div class="{~D:Record.Payload.cssClass~}">{~D:Record.Data.Name~}</div>');
|
|
34
|
+
|
|
35
|
+
_Pict.AppData.Items = [{ Name: 'Widget' }, { Name: 'Gadget' }];
|
|
36
|
+
_Pict.AppData.Config = { cssClass: 'product-card' };
|
|
37
|
+
|
|
38
|
+
_Pict.parseTemplate('{~TSWP:Item:AppData.Items:AppData.Config~}');
|
|
39
|
+
// '<div class="product-card">Widget</div><div class="product-card">Gadget</div>'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Related
|
|
43
|
+
|
|
44
|
+
- [TS](architecture/templating/ref-ts.md) -- Iterate without payload
|
|
45
|
+
- [TVS](architecture/templating/ref-tvs.md) -- Iterate over values with metadata
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Reference: TemplateValueSet (TVS)
|
|
2
|
+
|
|
3
|
+
Iterates over values of an object or array. Includes Key, Value, Index, and Count metadata.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~TemplateValueSet:HASH:ADDRESS~}` `{~TVS:HASH:ADDRESS~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-TemplateValueSet.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~TVS:TEMPLATE_HASH:DATA_ADDRESS~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| TEMPLATE_HASH | Yes | Hash of the template to render per value |
|
|
20
|
+
| DATA_ADDRESS | Yes | Address of an object or array |
|
|
21
|
+
|
|
22
|
+
## Record Properties
|
|
23
|
+
|
|
24
|
+
| Property | Description |
|
|
25
|
+
|----------|-------------|
|
|
26
|
+
| `Record.Key` | Array index or object key |
|
|
27
|
+
| `Record.Value` | The value at that key |
|
|
28
|
+
| `Record.Index` | Zero-based index |
|
|
29
|
+
| `Record.Count` | Total number of items |
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
_Pict.TemplateProvider.addTemplate('Tag', '<span>{~D:Record.Value~}</span>');
|
|
35
|
+
|
|
36
|
+
_Pict.AppData.Tags = ['js', 'node', 'express'];
|
|
37
|
+
_Pict.parseTemplate('{~TVS:Tag:AppData.Tags~}');
|
|
38
|
+
// '<span>js</span><span>node</span><span>express</span>'
|
|
39
|
+
|
|
40
|
+
// Object (sorted keys)
|
|
41
|
+
_Pict.AppData.Users = { '2': 'Bob', '1': 'Alice' };
|
|
42
|
+
_Pict.parseTemplate('{~TVS:Tag:AppData.Users~}');
|
|
43
|
+
// '<span>Alice</span><span>Bob</span>'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Related
|
|
47
|
+
|
|
48
|
+
- [TS](architecture/templating/ref-ts.md) -- Iterate objects as Record directly
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Reference: View (V)
|
|
2
|
+
|
|
3
|
+
Renders a registered Pict view inline.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~View:VIEW_HASH~}` `{~V:VIEW_HASH~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-View.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~V:VIEW_HASH~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| VIEW_HASH | Yes | Hash of a registered Pict view |
|
|
20
|
+
|
|
21
|
+
## Behavior
|
|
22
|
+
|
|
23
|
+
- Triggers the view's render pipeline
|
|
24
|
+
- Captures output to a virtual render target
|
|
25
|
+
- Returns the rendered string
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<div class="page">
|
|
31
|
+
{~V:HeaderView~}
|
|
32
|
+
<main>{~D:AppData.Content~}</main>
|
|
33
|
+
{~V:FooterView~}
|
|
34
|
+
</div>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Related
|
|
38
|
+
|
|
39
|
+
- [VRS](architecture/templating/ref-vrs.md) -- View with scope retention
|
|
40
|
+
- [P](architecture/templating/ref-pict.md) -- Pict instance reference
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Reference: ViewRetainingScope (VRS)
|
|
2
|
+
|
|
3
|
+
Renders a Pict view inline, passing the current scope through.
|
|
4
|
+
|
|
5
|
+
**Tags:** `{~ViewRetainingScope:VIEW_HASH~}` `{~VRS:VIEW_HASH~}`
|
|
6
|
+
|
|
7
|
+
**Source:** `pict/source/templates/Pict-Template-View-RetainingScope.js`
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
{~VRS:VIEW_HASH~}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Required | Description |
|
|
18
|
+
|-----------|----------|-------------|
|
|
19
|
+
| VIEW_HASH | Yes | Hash of a registered Pict view |
|
|
20
|
+
|
|
21
|
+
## Behavior
|
|
22
|
+
|
|
23
|
+
- Same as View, but calls `renderWithScope()` on the view
|
|
24
|
+
- The current Scope namespace is available inside the child view's templates
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<!-- Parent sets scope, child view reads it -->
|
|
30
|
+
{~VRS:ChildView~}
|
|
31
|
+
|
|
32
|
+
<!-- Inside ChildView's templates: -->
|
|
33
|
+
<div class="{~D:Scope.theme~}">{~D:Scope.title~}</div>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Related
|
|
37
|
+
|
|
38
|
+
- [V](architecture/templating/ref-view.md) -- View without scope retention
|
|
39
|
+
- [P](architecture/templating/ref-pict.md) -- Pict instance reference
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Solver Expressions
|
|
2
|
+
|
|
3
|
+
Solver expressions evaluate mathematical expressions using Fable's expression parser. They support arithmetic, built-in functions, string concatenation, and variable references resolved from data.
|
|
4
|
+
|
|
5
|
+
## Solve (S)
|
|
6
|
+
|
|
7
|
+
Evaluates a mathematical expression. Variables in the expression are resolved from the data at the given address.
|
|
8
|
+
|
|
9
|
+
**Tags:** `{~Solve:EXPRESSION~}` `{~S:EXPRESSION~}` or `{~S:EXPRESSION:DATA_ADDRESS~}`
|
|
10
|
+
|
|
11
|
+
**Parameters:**
|
|
12
|
+
|
|
13
|
+
| Parameter | Description |
|
|
14
|
+
|-----------|-------------|
|
|
15
|
+
| EXPRESSION | A math expression string |
|
|
16
|
+
| DATA_ADDRESS | Optional. Address of an object whose properties become variables in the expression. |
|
|
17
|
+
|
|
18
|
+
### Basic Arithmetic
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
_Pict.parseTemplate('{~S:100+55~}');
|
|
22
|
+
// '155'
|
|
23
|
+
|
|
24
|
+
_Pict.parseTemplate('{~S:2*3+4~}');
|
|
25
|
+
// '10'
|
|
26
|
+
|
|
27
|
+
_Pict.parseTemplate('{~S:100/3~}');
|
|
28
|
+
// '33.333333333333336'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Variables from Data
|
|
32
|
+
|
|
33
|
+
When you provide a data address, property names in the expression resolve against that object.
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
_Pict.AppData.Order = { Quantity: 3, UnitPrice: 24.99, TaxRate: 0.08 };
|
|
37
|
+
|
|
38
|
+
_Pict.parseTemplate('{~S:Quantity*UnitPrice:AppData.Order~}');
|
|
39
|
+
// '74.97'
|
|
40
|
+
|
|
41
|
+
_Pict.parseTemplate('{~S:Quantity*UnitPrice*(1+TaxRate):AppData.Order~}');
|
|
42
|
+
// '80.9892'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Built-in Functions
|
|
46
|
+
|
|
47
|
+
The expression parser supports several functions:
|
|
48
|
+
|
|
49
|
+
| Function | Description | Example |
|
|
50
|
+
|----------|-------------|---------|
|
|
51
|
+
| `ROUND(value, decimals)` | Round to N decimal places | `ROUND(3.14159, 2)` = `3.14` |
|
|
52
|
+
| `PI()` | The constant pi | `PI()` = `3.141592653589793` |
|
|
53
|
+
| `CONCAT(a, b, ...)` | String concatenation | `CONCAT("Hello", " ", "World")` = `Hello World` |
|
|
54
|
+
|
|
55
|
+
**Examples:**
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
_Pict.AppData.Circle = { Radius: 10 };
|
|
59
|
+
|
|
60
|
+
// Area of a circle
|
|
61
|
+
_Pict.parseTemplate('{~S:ROUND(PI()*Radius*Radius, 2):AppData.Circle~}');
|
|
62
|
+
// '314.16'
|
|
63
|
+
|
|
64
|
+
// Formatted output with CONCAT
|
|
65
|
+
_Pict.AppData.Metrics = { Height: 48 };
|
|
66
|
+
_Pict.parseTemplate('{~S:CONCAT("Height is ", Height, " units."):AppData.Metrics~}');
|
|
67
|
+
// 'Height is 48 units.'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Practical Patterns
|
|
71
|
+
|
|
72
|
+
**Invoice line totals:**
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
_Pict.TemplateProvider.addTemplate('LineItem',
|
|
76
|
+
'<tr><td>{~D:Record.Description~}</td><td>{~S:ROUND(Qty*Price,2):Record~}</td></tr>');
|
|
77
|
+
|
|
78
|
+
_Pict.AppData.Lines = [
|
|
79
|
+
{ Description: 'Widget', Qty: 5, Price: 9.99 },
|
|
80
|
+
{ Description: 'Gadget', Qty: 2, Price: 24.50 }
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
_Pict.parseTemplate('<table>{~TS:LineItem:AppData.Lines~}</table>');
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Percentage calculations:**
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
_Pict.AppData.Progress = { Completed: 37, Total: 50 };
|
|
90
|
+
|
|
91
|
+
_Pict.parseTemplate(
|
|
92
|
+
'{~S:ROUND(Completed/Total*100,1):AppData.Progress~}% complete');
|
|
93
|
+
// '74% complete'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## SolveByReference (SBR)
|
|
99
|
+
|
|
100
|
+
Resolves an equation string from a data address and evaluates it. The equation itself is stored in data rather than written directly in the template. Optionally resolves a data object and a Manyfest manifest for variable mapping.
|
|
101
|
+
|
|
102
|
+
**Tags:** `{~SolveByReference:EQUATION_ADDRESS~}` `{~SBR:EQUATION_ADDRESS~}` or `{~SBR:EQUATION_ADDRESS:DATA_ADDRESS:MANIFEST_ADDRESS~}`
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
|
|
106
|
+
| Parameter | Description |
|
|
107
|
+
|-----------|-------------|
|
|
108
|
+
| EQUATION_ADDRESS | Address containing the equation string |
|
|
109
|
+
| DATA_ADDRESS | Optional. Address of the data object for variable resolution |
|
|
110
|
+
| MANIFEST_ADDRESS | Optional. Address of a Manyfest instance for variable name mapping |
|
|
111
|
+
|
|
112
|
+
### Basic Usage
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
_Pict.AppData.Formula = 'Width * Height';
|
|
116
|
+
_Pict.AppData.Dimensions = { Width: 100, Height: 50 };
|
|
117
|
+
|
|
118
|
+
_Pict.parseTemplate('{~SBR:AppData.Formula:AppData.Dimensions~}');
|
|
119
|
+
// '5000'
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### With Manyfest Variable Mapping
|
|
123
|
+
|
|
124
|
+
When data uses nested addresses but the equation uses flat variable names, a Manyfest maps between them.
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
_Pict.AppData.Equation = 'Area = Width * Height';
|
|
128
|
+
_Pict.AppData.RectangleData = { Size: { Width: 100, Height: 50 } };
|
|
129
|
+
|
|
130
|
+
// Create a Manyfest that maps nested paths to flat names
|
|
131
|
+
_Pict.AppData.RectangleManifest = _Pict.newManyfest({
|
|
132
|
+
Scope: 'Rectangle',
|
|
133
|
+
Descriptors: {
|
|
134
|
+
'Size.Width': { Hash: 'Width' },
|
|
135
|
+
'Size.Height': { Hash: 'Height' }
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
_Pict.parseTemplate(
|
|
140
|
+
'{~SBR:AppData.Equation:AppData.RectangleData:AppData.RectangleManifest~}');
|
|
141
|
+
// '5000'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
SolveByReference is powerful for data-driven calculations where the formulas themselves are configurable. Pricing rules, scoring algorithms, or derived metrics can be stored as data and evaluated at render time without hardcoding the math in templates.
|
|
145
|
+
|
|
146
|
+
## When to Use Solve vs SolveByReference
|
|
147
|
+
|
|
148
|
+
| Scenario | Use |
|
|
149
|
+
|----------|-----|
|
|
150
|
+
| Fixed formula, data varies | `{~S:Qty*Price:Record~}` |
|
|
151
|
+
| Formula stored in data | `{~SBR:AppData.Formula:Record~}` |
|
|
152
|
+
| Nested data with variable mapping | `{~SBR:...^...^ManyfestInstance~}` |
|
|
153
|
+
| Simple constant math | `{~S:100+55~}` |
|