aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/render_in_place.rs
diff options
context:
space:
mode:
authorLibravatar Vicente Ramirez Perea <vicente.ramirez.perea@gmail.com>2019-03-05 22:47:17 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2019-03-18 10:19:48 +0100
commit5b2e9cf99274827079f70f10966f6284d075e624 (patch)
tree0ad69e32d5aa59defb1dfbdc1e684ca2de8d608d /testing/tests/render_in_place.rs
parent84d81e101bc706cfe85320df39c1f32828225153 (diff)
downloadaskama-5b2e9cf99274827079f70f10966f6284d075e624.tar.gz
askama-5b2e9cf99274827079f70f10966f6284d075e624.tar.bz2
askama-5b2e9cf99274827079f70f10966f6284d075e624.zip
Documenting feature render in template
Diffstat (limited to 'testing/tests/render_in_place.rs')
-rw-r--r--testing/tests/render_in_place.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/tests/render_in_place.rs b/testing/tests/render_in_place.rs
new file mode 100644
index 0000000..3d1b91e
--- /dev/null
+++ b/testing/tests/render_in_place.rs
@@ -0,0 +1,39 @@
+use askama::Template;
+#[derive(Template)]
+#[template(path = "render_in_place.html")]
+struct RenderInPlace<'a> {
+ s1: SectionOne<'a>,
+ s2: SectionTwo<'a>,
+ s3: &'a Vec<SectionOne<'a>>,
+}
+
+#[derive(Template)]
+#[template(path = "render_in_place_sec1.html")]
+struct SectionOne<'a> {
+ a: &'a str,
+ b: &'a str,
+}
+
+#[derive(Template)]
+#[template(path = "render_in_place_sec2.html")]
+struct SectionTwo<'a> {
+ c: &'a str,
+ d: &'a str,
+}
+
+#[test]
+fn test_render_in_place() {
+ let t = RenderInPlace {
+ s1: SectionOne { a: "A", b: "B" },
+ s2: SectionTwo { c: "C", d: "D" },
+ s3: &vec![
+ SectionOne { a: "1", b: "2" },
+ SectionOne { a: "A", b: "B" },
+ SectionOne { a: "a", b: "b" },
+ ],
+ };
+ assert_eq!(
+ t.render().unwrap(),
+ "Section 1: A=A\nB=B\nSection 2: C=C\nD=D\nSection 3 for:\n* A=1\nB=2\n* A=A\nB=B\n* A=a\nB=b\n"
+ );
+}