Update README
This commit is contained in:
@@ -3,11 +3,12 @@ WL is a powerful and flexible templating language for the web.
|
|||||||
|
|
||||||
Here's an example template in WL with a recursive comment view element:
|
Here's an example template in WL with a recursive comment view element:
|
||||||
```html
|
```html
|
||||||
posts = [
|
let posts = [
|
||||||
{
|
{
|
||||||
author: "UserA",
|
author: "UserA",
|
||||||
title: "I'm the first post",
|
title: "I'm the first post",
|
||||||
content: "Sup everyone!",
|
content: "Sup everyone!",
|
||||||
|
date: "1 Jan 2025",
|
||||||
comments: [
|
comments: [
|
||||||
{
|
{
|
||||||
author: "UserB",
|
author: "UserB",
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
case WL_ERROR:
|
case WL_ERROR:
|
||||||
done = true;
|
done = true;
|
||||||
|
printf("%s\n", err);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WL_VAR:
|
case WL_VAR:
|
||||||
|
|||||||
@@ -1,5 +1,53 @@
|
|||||||
let set = {a: "G", b: "T", c: "K"}
|
let posts = [
|
||||||
|
{
|
||||||
for item, i in set: {
|
author: "UserA",
|
||||||
<li>\item \i \set[item]</li>
|
title: "I'm the first post",
|
||||||
|
content: "Sup everyone!",
|
||||||
|
date: "1 Jan 2025",
|
||||||
|
comments: [
|
||||||
|
{
|
||||||
|
author: "UserB",
|
||||||
|
content: "Hello! This is a comment!",
|
||||||
|
comments: [
|
||||||
|
{
|
||||||
|
author: "UserA",
|
||||||
|
content: "Hello to you!",
|
||||||
|
comments: []
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
fun comment(c)
|
||||||
|
<div>
|
||||||
|
<a>\c.author</a>
|
||||||
|
<p>\c.content</p>
|
||||||
|
\for subc in c.comments:
|
||||||
|
comment(subc)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>List of posts</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
\for post in posts:
|
||||||
|
<div class="post">
|
||||||
|
<h2>
|
||||||
|
\post.title
|
||||||
|
</h2>
|
||||||
|
<span>
|
||||||
|
Posted on \post.date by \post.author
|
||||||
|
</span>
|
||||||
|
<p>
|
||||||
|
\post.content
|
||||||
|
</p>
|
||||||
|
<div class="comments">
|
||||||
|
\for c in post.comments:
|
||||||
|
comment(c)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user