aboutsummaryrefslogtreecommitdiff
path: root/examples/template-demo/templates/index.html
blob: 2a084850ffe205bc1c7d6b8617839d81f86845a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{title}}</title>
    <link rel="stylesheet" href="/static/style.css">
</head>
<body>
    <div class="container">
        {{include "header.html"}}

        <h1>{{page_heading}}</h1>

        <p>Welcome, <span class="highlight">{{username}}</span>! This page demonstrates the templating capabilities of the Beaker web framework.</p>

        <h2>Simple Variable Substitution</h2>
        <p>Your favourite colour is: <span class="highlight">{{favourite_colour}}</span></p>
        <p>The current year is: <span class="highlight">{{current_year}}</span></p>
        <p>This is a safe string: <span class="code-block">{{safe_html|safe}}</span></p>
        <p>This is an unsafe string (will be escaped): <span class="code-block">{{unsafe_html}}</span></p>

        <h2>List of Features (String Array)</h2>
        <p>Here are some features:</p>
        <ul>
            {{for feature in features}}
                <li>{{feature}}</li>
            {{endfor}}
        </ul>

        <h2>User Data (Array of Arrays)</h2>
        <p>Here's some user information:</p>
        <ul>
            {{for user_row in users}}
                <li>
                    Name: <span class="highlight">{{user_row[0]}}</span>,
                    Age: <span class="highlight">{{user_row[1]}}</span>,
                    City: <span class="highlight">{{user_row[2]}}</span>
                </li>
            {{endfor}}
        </ul>

        <h2>Conditional Statements (if/elif/else)</h2>
        
        <h3>Simple truthy check</h3>
        <p>
        {{if user_logged_in}}
            <span class="highlight">User is logged in!</span>
        {{else}}
            <span>User is NOT logged in.</span>
        {{endif}}
        </p>

        <h3>Equality check (role == "admin")</h3>
        <p>
        {{if role == "admin"}}
            <span class="highlight">Welcome, Admin! You have full access.</span>
        {{elif role == "user"}}
            <span>Welcome, User! You have standard access.</span>
        {{else}}
            <span>Welcome, Guest! You have limited access.</span>
        {{endif}}
        </p>

        <h3>Not equal check (status != "inactive")</h3>
        <p>
        {{if status != "inactive"}}
            <span class="highlight">Account is active.</span>
        {{else}}
            <span>Account is inactive.</span>
        {{endif}}
        </p>

        <h3>Variable existence check (exists)</h3>
        <p>
        {{if exists username}}
            <span class="highlight">Username exists!</span>
        {{else}}
            <span>Username does NOT exist.</span>
        {{endif}}
        </p>
        
        <h3>Variable existence check (not exists)</h3>
        <p>
        {{if not exists missing_var}}
            <span class="highlight">missing_var does NOT exist (as expected)</span>
        {{else}}
            <span>missing_var exists (unexpected!)</span>
        {{endif}}
        </p>

        <div class="footer">
            <p>Rendered at: {{timestamp}}</p>
        </div>
    </div>
</body>
</html>