aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-23 17:07:53 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-23 17:07:53 +0200
commit9f34349cbaf5b7933c0ab690af5f626c0322c5ca (patch)
treedcefb014df2bd4bb862431d68e6a9e6703195e25
parentf1422f5c66509f251e1e3e2cbd1752131dd1301f (diff)
downloadaskama-9f34349cbaf5b7933c0ab690af5f626c0322c5ca.tar.gz
askama-9f34349cbaf5b7933c0ab690af5f626c0322c5ca.tar.bz2
askama-9f34349cbaf5b7933c0ab690af5f626c0322c5ca.zip
Add test for Index operation
Diffstat (limited to '')
-rw-r--r--testing/tests/simple.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs
index 28a6a0a..ff63587 100644
--- a/testing/tests/simple.rs
+++ b/testing/tests/simple.rs
@@ -3,6 +3,8 @@ extern crate askama;
use askama::Template;
+use std::collections::HashMap;
+
#[derive(Template)]
#[template(path = "simple.html")]
struct VariablesTemplate<'a> {
@@ -233,3 +235,17 @@ fn test_minus() {
let t = MinusTemplate { foo: 1 };
assert_eq!(t.render().unwrap(), "Hello");
}
+
+#[derive(Template)]
+#[template(source = "{{ foo[\"bar\"] }}", ext = "txt", print = "code")]
+struct IndexTemplate {
+ foo: HashMap<String, String>,
+}
+
+#[test]
+fn test_index() {
+ let mut foo = HashMap::new();
+ foo.insert("bar".into(), "baz".into());
+ let t = IndexTemplate { foo };
+ assert_eq!(t.render().unwrap(), "baz");
+}