mirror of
https://git.madhouse-project.org/algernon/iocaine.git
synced 2025-02-24 02:18:47 +01:00
Implement per-host templates
Fixes #7. Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
parent
5be1a9169e
commit
2bdfa92d3e
2 changed files with 9 additions and 2 deletions
|
@ -3,7 +3,9 @@ title: Templating
|
|||
description: Changing the Iocaine template
|
||||
---
|
||||
|
||||
`iocaine` uses [Handlebars](https://handlebarsjs.com/) for templating, and uses only a single template, `main`. See the Handlebars for basic syntax. A [default template][template:Default] is provided, but if you want to change it, you can configure a [template directory](@/configuration/index.md#templates), and place a customized `main.hbs` file in it, and `iocane` will use that over the default.
|
||||
`iocaine` uses [Handlebars](https://handlebarsjs.com/) for templating, and will look for a template named `hosts/$host.hbs` (where `$host` is whatever is in the hosts header), but fall back on `main`, if a host-specific template is not found.
|
||||
|
||||
See the Handlebars for basic syntax. A [default template][template:Default] is provided, but if you want to change it, you can configure a [template directory](@/configuration/index.md#templates), and place a customized `main.hbs` file in it, and `iocane` will use that over the default. Naturally, you can also place host-specific templates in a `hosts/` subdirectory.
|
||||
|
||||
[template:default]: https://git.madhouse-project.org/algernon/iocaine/src/branch/main/templates/main.hbs
|
||||
|
||||
|
|
|
@ -144,6 +144,11 @@ impl AssembledStatisticalSequences {
|
|||
links,
|
||||
};
|
||||
|
||||
handlebars.render("main", &data).unwrap()
|
||||
let host_template = &format!("hosts/{}", host);
|
||||
if handlebars.has_template(host_template) {
|
||||
handlebars.render(host_template, &data).unwrap()
|
||||
} else {
|
||||
handlebars.render("main", &data).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue