forked from fastn-stack/ftd.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.ftd
105 lines (65 loc) · 1.85 KB
/
list.ftd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/-- ft-core.concept:
-- ft.page-with-toc: `list`
toc: $config.data-toc
sub-sections: $config.doc-header
-- ft.markdown:
`list` keyword can be used to create a list or an array in `ftd`.
-- ft.h1: Declaring a `list`
-- ft.code: a list of integer
lang: ftd
\-- integer list primes:
-- ft.markdown:
Here we have declared a new variable called `primes`, which is a `list` of
`integer`s. When the list is created it is empty.
-- ft.h1: Adding values to list
The name of `list` can be used to insert more values in that list:
-- ft.code:
lang: ftd
\-- primes: 1
\-- primes: 3
\-- primes: 5
\-- primes: 7
\-- primes: 11
-- ft.markdown:
We have inserted 5 `integer`s to our `list` named `primes`.
-- ft.code:
lang: ftd
\-- record person:
name: caption
bio: body
\-- person list people:
\-- people: Amit Upadhyay
Amit is CEO of FifthTry.
\-- people: Shobhit Sharma
Shobhit is a developer at FifthTry.
-- ft.markdown:
Here we have created a `list` of `person` objects, called it `people`, and
created two `person` objects and inserted them the `people` list.
-- ft.h1: `$processor$`
A list can be created using platform provided processors:
-- ft.code:
lang: ftd
\-- string list foo:
$processor$: some-list
-- ft.markdown:
Here the value of the list will be provided by the `some-list` processor.
If we already have a list we can insert values to it using `$processor$` as well:
-- ft.code:
lang: ftd
\-- string list foo:
\-- foo:
$processor$: some-list
-- ft.h1: Reading A `list` from Rust
You can use the `.get()` method to read a `list`:
-- ft.code:
lang: rs
#[derive(serde::Deserialize)]
struct Person {
name: String,
bio: String,
}
let doc = ftd::p2::Document::from("some/id", source, lib)?;
let people: Vec<Person> = doc.get("people")?;
-- ft.markdown:
You can read more details of reading `ftd` files ["Reading FTD Files"](/reading-data/)
guide.