From 76b9063193528abfba3eaa9aee003465687ff8af Mon Sep 17 00:00:00 2001 From: Rasmus Kaj Date: Tue, 25 Jun 2024 19:09:21 +0200 Subject: [PATCH] Add failing test. --- examples/simple/src/main.rs | 15 +++++----- .../templates/page/intermediate.rs.html | 12 ++++++++ examples/simple/templates/page/page.rs.html | 4 +-- examples/warp03/templates/base.rs.html | 21 ++++++++++++++ examples/warp03/templates/error.rs.html | 29 +++++-------------- examples/warp03/templates/page.rs.html | 20 ++----------- 6 files changed, 53 insertions(+), 48 deletions(-) create mode 100644 examples/simple/templates/page/intermediate.rs.html create mode 100644 examples/warp03/templates/base.rs.html diff --git a/examples/simple/src/main.rs b/examples/simple/src/main.rs index 835326a..659d76d 100644 --- a/examples/simple/src/main.rs +++ b/examples/simple/src/main.rs @@ -257,16 +257,17 @@ fn test_page_with_base() { r2s(|o| page::page_html(o, "World")), "\ \n\ - \n Hello World!\ - \n \ + \n Hello World!\n\ + \n \n\ \n\ \n \ \n

Hello World!

\ - \n \ - \n

This is page content for World

\ - \n\ - \n \ - \n\n\n" + \n \n
\ + \n \ + \n

This is page content for World

\n\ + \n
\n\ + \n\n \ + \n\n\n\n" ); } diff --git a/examples/simple/templates/page/intermediate.rs.html b/examples/simple/templates/page/intermediate.rs.html new file mode 100644 index 0000000..3e29127 --- /dev/null +++ b/examples/simple/templates/page/intermediate.rs.html @@ -0,0 +1,12 @@ +@use super::base_html; + +@(title: &str, content: Content, meta: Content) + +@:base_html(title, { +
+ @:content() +
+ +}, { +@:meta() +}) diff --git a/examples/simple/templates/page/page.rs.html b/examples/simple/templates/page/page.rs.html index d08930b..304178d 100644 --- a/examples/simple/templates/page/page.rs.html +++ b/examples/simple/templates/page/page.rs.html @@ -1,8 +1,8 @@ -@use super::base_html; +@use super::intermediate_html; @(who: &str) -@:base_html(&format!("Hello {who}!"), { +@:intermediate_html(&format!("Hello {who}!"), {

This is page content for @who

}, { diff --git a/examples/warp03/templates/base.rs.html b/examples/warp03/templates/base.rs.html new file mode 100644 index 0000000..66d126e --- /dev/null +++ b/examples/warp03/templates/base.rs.html @@ -0,0 +1,21 @@ +@use super::statics::*; +@use crate::footer; + +@(title: &str, htmlargs: Content, content: Content) + + + + + @title + + + + +
+

@title

+ + @:content() +
+ @:footer() + + diff --git a/examples/warp03/templates/error.rs.html b/examples/warp03/templates/error.rs.html index 8ce6610..6c0ac03 100644 --- a/examples/warp03/templates/error.rs.html +++ b/examples/warp03/templates/error.rs.html @@ -1,25 +1,10 @@ -@use super::statics::*; -@use crate::footer; +@use super::base_html; @use warp::http::StatusCode; @(code: StatusCode, message: &str) - - - - - Error @code.as_u16(): @code.canonical_reason().unwrap_or("error") - - - - -
-

@code.canonical_reason().unwrap_or("error")

- -

@message

-

We are sorry about this. - In a real application, this would mention the incident having - been logged, and giving contact details for further reporting.

-
- @:footer() - - +@:base_html(code.canonical_reason().unwrap_or("Error"), { class="error"}, { +

@message

+

We are sorry about this. + In a real application, this would mention the incident having + been logged, and giving contact details for further reporting.

+}) diff --git a/examples/warp03/templates/page.rs.html b/examples/warp03/templates/page.rs.html index 8dce6e4..001c689 100644 --- a/examples/warp03/templates/page.rs.html +++ b/examples/warp03/templates/page.rs.html @@ -1,19 +1,8 @@ @use super::statics::*; -@use crate::footer; +@use super::base_html; @(paras: &[(&str, usize)]) - - - - - Example - - - - -
-

Example

- +@:base_html("Example", {}, {
Squirrel! @@ -30,7 +19,4 @@

Example

This is a @order paragraph. } } -
- @:footer() - - +})