Skip to content

Commit

Permalink
Add failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Jun 25, 2024
1 parent defcf7c commit 76b9063
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 48 deletions.
15 changes: 8 additions & 7 deletions examples/simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,17 @@ fn test_page_with_base() {
r2s(|o| page::page_html(o, "World")),
"<!doctype html>\
\n<html>\
\n <head><title>Hello World!</title>\
\n <meta property=\"og:description\" content=\"A simple example\"/>\
\n <head><title>Hello World!</title>\n\
\n <meta property=\"og:description\" content=\"A simple example\"/>\n\
\n</head>\
\n <body>\
\n <h1>Hello World!</h1>\
\n \
\n <p>This is page content for World</p>\
\n\
\n </body>\
\n</html>\n\n"
\n \n<div>\
\n \
\n <p>This is page content for World</p>\n\
\n</div>\n<footer>A footer common to some pages.</footer>\
\n\n </body>\
\n</html>\n\n\n"
);
}

Expand Down
12 changes: 12 additions & 0 deletions examples/simple/templates/page/intermediate.rs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@use super::base_html;

@(title: &str, content: Content, meta: Content)

@:base_html(title, {
<div>
@:content()
</div>
<footer>A footer common to some pages.</footer>
}, {
@:meta()
})
4 changes: 2 additions & 2 deletions examples/simple/templates/page/page.rs.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use super::base_html;
@use super::intermediate_html;

@(who: &str)

@:base_html(&format!("Hello {who}!"), {
@:intermediate_html(&format!("Hello {who}!"), {
<p>This is page content for @who</p>
}, {
<meta property="og:description" content="A simple example"/>
Expand Down
21 changes: 21 additions & 0 deletions examples/warp03/templates/base.rs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@use super::statics::*;
@use crate::footer;

@(title: &str, htmlargs: Content, content: Content)

<!doctype html>
<html lang="en"@:htmlargs()>
<head>
<title>@title</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/static/@style_css.name"/>
</head>
<body>
<main>
<h1>@title</h1>

@:content()
</main>
@:footer()
</body>
</html>
29 changes: 7 additions & 22 deletions examples/warp03/templates/error.rs.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
@use super::statics::*;
@use crate::footer;
@use super::base_html;
@use warp::http::StatusCode;

@(code: StatusCode, message: &str)

<!doctype html>
<html lang="en" class="error">
<head>
<title>Error @code.as_u16(): @code.canonical_reason().unwrap_or("error")</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/static/@style_css.name"/>
</head>
<body>
<main>
<h1>@code.canonical_reason().unwrap_or("error")</h1>

<p>@message</p>
<p>We are sorry about this.
In a real application, this would mention the incident having
been logged, and giving contact details for further reporting.</p>
</main>
@:footer()
</body>
</html>
@:base_html(code.canonical_reason().unwrap_or("Error"), { class="error"}, {
<p>@message</p>
<p>We are sorry about this.
In a real application, this would mention the incident having
been logged, and giving contact details for further reporting.</p>
})
20 changes: 3 additions & 17 deletions examples/warp03/templates/page.rs.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
@use super::statics::*;
@use crate::footer;
@use super::base_html;

@(paras: &[(&str, usize)])

<!doctype html>
<html lang="en">
<head>
<title>Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/static/@style_css.name"/>
</head>
<body>
<main>
<h1>Example</h1>

@:base_html("Example", {}, {
<figure>
<img src="/static/@squirrel_jpg.name" alt="Squirrel!"
width="240" height="160"/>
Expand All @@ -30,7 +19,4 @@ <h1>Example</h1>
This is a @order paragraph.
}
}
</main>
@:footer()
</body>
</html>
})

0 comments on commit 76b9063

Please sign in to comment.