From 9f34349cbaf5b7933c0ab690af5f626c0322c5ca Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 23 Jun 2018 17:07:53 +0200 Subject: Add test for Index operation --- testing/tests/simple.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'testing/tests') 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, +} + +#[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"); +} -- cgit