1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: document $tmpl

This commit is contained in:
Alexander Medvednikov 2021-02-01 15:45:45 +01:00
parent c537578481
commit 6804fdaa56

View File

@ -3346,6 +3346,56 @@ executable, increasing your binary size, but making it more self contained
and thus easier to distribute. In this case, `f.data()` will cause *no IO*,
and it will always return the same data.
#### $tmpl for embedding and parsing V template files
V has a simple template language for text and html templates, and they can easily
be embedded via `$tmpl('path/to/template.txt')`:
```v ignore
fn build() string {
name := 'Peter'
age := 25
numbers := [1, 2, 3]
return $tmpl('1.txt')
}
fn main() {
println(build())
}
```
1.txt:
```
name: @name
age: @age
numbers: @numbers
@for number in numbers
@number
@end
```
output:
```
name: Peter
age: 25
numbers: [1, 2, 3]
1
2
3
```
#### $env
```v