Added examples of extend and embed

This commit is contained in:
Tom Holland 2016-11-07 09:56:13 -08:00 committed by GitHub
parent 9a36e7510b
commit 2d64a5dff7
1 changed files with 46 additions and 0 deletions

View File

@ -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.