94 lines
1.7 KiB
Text
94 lines
1.7 KiB
Text
```
|
|
apply {{mustache_name}} to {{pages}}
|
|
A = /html/head/text()
|
|
struct B
|
|
C default("n/a") = //table[@class="wikitable sortable"]/tr/td[4]/a/text()
|
|
D default("0") = //table[@class="wikitable sortable"]/tr/td[3]/text()
|
|
struct E
|
|
F = /html/head/inner_names/text()
|
|
G = /html/head/inner_probabilities/text()
|
|
end
|
|
H = /html/head/inner_names/text()
|
|
end
|
|
I = /html/head/inner_names/text()
|
|
end
|
|
|
|
==mustache_name
|
|
blah
|
|
==end
|
|
```
|
|
|
|
|
|
The above should result in the following:
|
|
|
|
```
|
|
A[]
|
|
B[] --- C
|
|
--- D
|
|
--- E[] --- F
|
|
--- G
|
|
--- H
|
|
--- I[]
|
|
```
|
|
|
|
For example, given these query results:
|
|
|
|
```
|
|
A[] = {a1, a2, a3}
|
|
C = c1
|
|
D[] = {d1, d2}
|
|
F[] = {f1, f2, f3}
|
|
G = g1
|
|
h = h1
|
|
i = i1
|
|
```
|
|
|
|
then the complete result in tree form shall be:
|
|
|
|
```
|
|
{
|
|
A => [a1, a2, a3],
|
|
B => [
|
|
{
|
|
C => c1,
|
|
D => d1,
|
|
E => [
|
|
{
|
|
F => f1,
|
|
G => g1
|
|
}, {
|
|
F => f2,
|
|
G => ""
|
|
}, {
|
|
F => f3,
|
|
G => ""
|
|
}
|
|
],
|
|
H => h1
|
|
}, {
|
|
C => "",
|
|
D => d2,
|
|
E => [
|
|
{
|
|
F => f1,
|
|
G => g1
|
|
}, {
|
|
F => f2,
|
|
G => ""
|
|
}, {
|
|
F => f3,
|
|
G => ""
|
|
}
|
|
],
|
|
H => ""
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
Please note that:
|
|
|
|
* arrays inside a struct turn the struct itself into an array, while its items become just single item values
|
|
* if a struct contains no arrays, then the struct shall not become an array - that is, a struct generates an array with as many elements as the largest element in the struct itself
|
|
* there are as many of any one struct as the size of the largest array inside it
|
|
* nested structs get duplicated in every outer struct they are part of; in the example above E has as many elements as there items in F (2, the largest between F and G), and the whole array of E is duplicated in every element of B
|