added demo for template response

This commit is contained in:
overflowerror 2021-05-23 17:19:06 +02:00
parent 8889fd64ec
commit 602b017745
2 changed files with 17 additions and 0 deletions

View file

@ -26,3 +26,8 @@ response_t user(ctx_t ctx) {
return jsonResponse(200, user_t, &user);
}
GET("/template", template);
response_t template(ctx_t ctx) {
return templateResponse(200, "demo.templ", "Page Title", "Overflow");
}

12
demo/demo.templ Normal file
View file

@ -0,0 +1,12 @@
{$ char* title, char* name $}
%%
<!DOCTYPE html>
<html>
<head>
<title>{{ "%s", title }}</title>
</head>
<body>
<h1>Hello {{ "%s", name }}!</h1>
</body>
</html>