From 647c8c0b52114ab1d6dde8b7399652c926ec9a9a Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 8 Aug 2017 12:49:04 +0200 Subject: Add some documentation about includes --- askama/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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`). -- cgit