Skip to content

Commit

Permalink
docs/recursive: add documentation hints for recursive structures
Browse files Browse the repository at this point in the history
Closes #220
  • Loading branch information
drahnr committed Apr 24, 2019
1 parent e29792e commit f581db8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions askama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,29 @@
//!
//! Askama supports block comments delimited by `{#` and `#}`.
//!
//!
//! ## Recursive Structures
//!
//! Recursive implementations should preferably use a custom iterator and
//! use a plain loop. If that is not doable, call `.render()`
//! directly by using an expression as shown below.
//! Including self does not work, see #105 and #220 .
//!
//! ```rust
//! use askama::Template;
//!
//! #[derive(Template)]
//! #[template(source = r#"
//! //! {% for item in children %}
//! {{ item.render().unwrap() }}
//! {% endfor %}
//! "#, ext = "html", escape = "none")]
//! struct Item<'a> {
//! name: &'a str,
//! children: &'a [Item<'a>],
//! }
//! ```
//!
//! # Optional functionality
//!
//! ## Rocket integration
Expand Down

0 comments on commit f581db8

Please sign in to comment.