gazetta_render_ext/
assets.rs1use gazetta_core::render::Gazetta;
17use gazetta_core::view::Site;
18use horrorshow::html;
19use horrorshow::prelude::*;
20
21pub struct Assets<'a, G>(pub &'a Site<'a, G>)
23where
24 G: Gazetta + 'a,
25 G::SiteMeta: 'a,
26 G::PageMeta: 'a;
27
28impl<'a, G> RenderOnce for Assets<'a, G>
29where
30 G: Gazetta + 'a,
31 G::SiteMeta: 'a,
32 G::PageMeta: 'a,
33{
34 fn render_once(self, tmpl: &mut TemplateBuffer) {
35 self.render(tmpl)
36 }
37}
38
39impl<'a, G> RenderMut for Assets<'a, G>
40where
41 G: Gazetta + 'a,
42 G::SiteMeta: 'a,
43 G::PageMeta: 'a,
44{
45 fn render_mut(&mut self, tmpl: &mut TemplateBuffer) {
46 self.render(tmpl)
47 }
48}
49
50impl<'a, G> Render for Assets<'a, G>
51where
52 G: Gazetta + 'a,
53 G::SiteMeta: 'a,
54 G::PageMeta: 'a,
55{
56 fn render(&self, tmpl: &mut TemplateBuffer) {
57 tmpl << html! {
58 base(href=self.0.prefix);
59 @ if let Some(css) = self.0.stylesheets {
60 link(rel="stylesheet", href=css);
61 }
62 @ if let Some(js) = self.0.javascript {
63 script(async, src=js) {}
64 }
65 @ if let Some(icon) = self.0.icon {
66 link(rel="shortcut icon", href=icon);
67 }
68 };
69 }
70}