aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-08 12:49:04 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-08 12:49:04 +0200
commit647c8c0b52114ab1d6dde8b7399652c926ec9a9a (patch)
tree7c86b741f9aea16a0c607eaa58363029715da0f8
parent52dee62de887f2eb455223ebce9a6dd3ef1aebe8 (diff)
downloadaskama-647c8c0b52114ab1d6dde8b7399652c926ec9a9a.tar.gz
askama-647c8c0b52114ab1d6dde8b7399652c926ec9a9a.tar.bz2
askama-647c8c0b52114ab1d6dde8b7399652c926ec9a9a.zip
Add some documentation about includes
-rw-r--r--askama/src/lib.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index 8a431c5..ed2a6c9 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -182,6 +182,26 @@
//! {% endif %}
//! ```
//!
+//! ### Include
+//!
+//! The *include* statement lets you split large or repetitive blocks into
+//! separate template files. Included templates get full access to the context
+//! in which they're used, including local variables like those from loops:
+//!
+//! ```text
+//! {% for i in iter %}
+//! {% include "item.html" %}
+//! {% endfor %}
+//! ```
+//!
+//! ```text
+//! * Item: {{ i }}
+//! ```
+//!
+//! The path to include must be a string literal, so that it is known at
+//! compile time. You can use include within the branches of an if/else
+//! block to use includes more dynamically.
+//!
//! ## Expressions
//!
//! Askama supports string literals (`"foo"`) and integer literals (`1`).