mirror of https://github.com/vapor/docs.git
Added examples of extend and embed
This commit is contained in:
parent
9a36e7510b
commit
2d64a5dff7
|
|
@ -105,6 +105,52 @@ The double token, `##` indicates a chain. If the previous tag fails, this tag wi
|
|||
}
|
||||
```
|
||||
|
||||
#### Extending
|
||||
|
||||
```swift
|
||||
/// base.leaf
|
||||
<!DOCTYPE html>
|
||||
#import("html")
|
||||
|
||||
/// html.leaf
|
||||
#extend("base")
|
||||
|
||||
#export("html") {
|
||||
<html></html>
|
||||
}
|
||||
```
|
||||
|
||||
Leaf renders this as:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html></html>
|
||||
```
|
||||
|
||||
#### Embedding
|
||||
|
||||
```swift
|
||||
/// base.leaf
|
||||
<!DOCTYPE html>
|
||||
#import("html")
|
||||
|
||||
/// html.leaf
|
||||
#extend("base")
|
||||
|
||||
#export("html") {
|
||||
<html>#embed("body")</html>
|
||||
}
|
||||
|
||||
/// body.leaf
|
||||
<body></body>
|
||||
```
|
||||
Leaf renders this as:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html><body></body></html>
|
||||
```
|
||||
|
||||
### Custom Tags
|
||||
|
||||
Look at the existing tags for advanced scenarios, let's look at a basic example by creating `Index` together. This tag will take two arguments, an array, and an index to access.
|
||||
|
|
|
|||
Loading…
Reference in New Issue