|
12 | 12 | //! Templates (and static assets) are included in the compiled |
13 | 13 | //! program, which can be a single binary. |
14 | 14 | //! |
| 15 | +//! The template syntax, which is inspired by [Twirl], the Scala-based |
| 16 | +//! template engine in [Play framework], is documented in |
| 17 | +//! the [Template_syntax] module. |
| 18 | +//! A sample template may look like this: |
| 19 | +//! |
| 20 | +//! ```html |
| 21 | +//! @use any::rust::Type; |
| 22 | +//! |
| 23 | +//! @(name: &str, items: &[Type]) |
| 24 | +//! |
| 25 | +//! <html> |
| 26 | +//! <head><title>@name</title></head> |
| 27 | +//! <body> |
| 28 | +//! @if items.is_empty() { |
| 29 | +//! <p>There are no items.</p> |
| 30 | +//! } else { |
| 31 | +//! <p>There are @items.len() items.</p> |
| 32 | +//! <ul> |
| 33 | +//! @for item in items { |
| 34 | +//! <li>@item</li> |
| 35 | +//! } |
| 36 | +//! </ul> |
| 37 | +//! } |
| 38 | +//! <body> |
| 39 | +//! </html> |
| 40 | +//! ``` |
| 41 | +//! |
15 | 42 | //! # Getting started |
16 | 43 | //! |
17 | 44 | //! The aim of ructe is to have your templates and static files accessible to |
|
64 | 91 | //! assert_eq!(buf, b"<h1>Hello World!</h1>\n"); |
65 | 92 | //! ``` |
66 | 93 | //! |
67 | | -//! # Template syntax |
68 | | -//! |
69 | | -//! The template syntax, which is inspired by [Twirl], the Scala-based |
70 | | -//! template engine in [Play framework], is documented in |
71 | | -//! the [Template_syntax] module. |
72 | | -//! A sample template may look like this: |
73 | | -//! |
74 | | -//! ```html |
75 | | -//! @use any::rust::Type; |
76 | | -//! |
77 | | -//! @(name: &str, items: &[Type]) |
78 | | -//! |
79 | | -//! <html> |
80 | | -//! <head><title>@name</title></head> |
81 | | -//! <body> |
82 | | -//! @if items.is_empty() { |
83 | | -//! <p>There are no items.</p> |
84 | | -//! } else { |
85 | | -//! <p>There are @items.len() items.</p> |
86 | | -//! <ul> |
87 | | -//! @for item in items { |
88 | | -//! <li>@item</li> |
89 | | -//! } |
90 | | -//! </ul> |
91 | | -//! } |
92 | | -//! <body> |
93 | | -//! </html> |
94 | | -//! ``` |
95 | | -//! |
96 | 94 | //! There are some [examples in the repository]. |
97 | 95 | //! There is also a separate example of |
98 | 96 | //! [using ructe with warp and diesel]. |
|
0 commit comments