2020-06-19 01:53:16 -04:00
# Includes
You can also include another template inside templates using `include!` macro.
Consider the following example.
- `templates/header.stpl`
2021-01-03 04:00:29 -05:00
``` html
2020-06-19 01:53:16 -04:00
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / >
< meta name = "format-detection" content = "telephone=no" >
< link rel = "icon" type = "image/x-icon" href = "favicon.ico" >
```
- `templates/index.stpl`
2021-01-03 04:00:29 -05:00
``` rhtml
2020-06-19 01:53:16 -04:00
< html >
< head >
< % include!("./header.stpl"); %>
< / head >
< body >
Main contents
< / body >
< / html >
```
Then you can see the `header.stpl` is embedded in the output.
2021-01-03 04:00:29 -05:00
``` html
2020-06-19 01:53:16 -04:00
< html >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / >
< meta name = "format-detection" content = "telephone=no" >
< link rel = "icon" type = "image/x-icon" href = "favicon.ico" >
< / head >
< body >
Main contents
< / body >
< / html >
```
Like [`std::include!` ](https://doc.rust-lang.org/std/macro.include.html ) macro in Rust, the provided path is interpreted as a relative path to the current template file.
!!! Warning
The path format is platform-specific. You must use `\` character as a separator on Windows.