Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/recursive: add documentation hints for recursive structures #235

Merged
merged 1 commit into from
Apr 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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