This repository has been archived by the owner on Sep 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.htm
204 lines (154 loc) · 3.86 KB
/
test.htm
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
{# Echo Data #}
Hello, {{ name }}.
The current UNIX timestamp is {{ 'now'|date('U') }}.
{# Echoing Data After Checking For Existence #}
{{ isset($name) ? $name : 'Default' }}
{{ name or 'Default' }}
{# Displaying Raw Text With Curly Braces #}
{% verbatim %}{{ This will not be processed by Twig }}{% endverbatim %}
{# Do not escape data #}
Hello, {{ name|raw }}.
{# Escape Data #}
Hello, {{ name|e }}.
<?php echo $name; ?>
<?= $name; ?>
<?php
foreach (range(1, 10) as $number) {
echo $number;
}
?>
{# Define Twig Layout #}
<html>
<head>
<title>
{{ this.page.title ?: 'App Name' }}
</title>
</head>
<body>
{% placeholder sidebar default %}
This is the master sidebar.
{% endplaceholder %}
<div class="container">
{% page %}
</div>
</body>
</html>
{# Placeholder #}
{% placeholder section default %}
Default Content
{% endplaceholder %}
{# Put #}
{% put section %}
<p>This is my body content.</p>
{% endput %}
{# If Statement #}
{% if records|length == 1 %}
I have one record!
{% elseif records|length > 1 %}
I have multiple records!
{% else %}
I don't have any records!
{% endif %}
{% if not user %}
You are not signed in.
{% endif %}
{# Loops #}
{% for i in 0..10 %}
The current value is {{ i }}
{% endfor %}
{% for user in users %}
<p>This is user {{ user.id }}</p>
{% endfor %}
{% for user in users %}
<li>{{ user.name }}</li>
{% else %}
<p>No users</p>
{% endfor %}
{# Partial #}
{% partial 'name' %}
{% partial 'name' some='data' %}
{# Content #}
{% content 'name' %}
{% content 'name' some='data' %}
{# Component #}
{% component 'name' %}
{% component 'name' some='data' %}
{# Overwriting Sections #}
@extends('list.item.container')
@section('list.item.content')
<p>This is an item of type {{ item->type }}</p>
@overwrite
{# Displaying Language Lines #}
{{ 'language.line'|trans }}
{{ 'language.line'|transchoice(1) }}
{# This comment will not be in the rendered HTML #}
{#
This comment will not be in the rendered HTML
This comment will not be in the rendered HTML
This comment will not be in the rendered HTML
#}
{# Advanced loops #}
{% for key, val in stuff %}
{{ loop.index0 }} {# int, zero based #}
{{ loop.index }} {# int, starts at 1 #}
{{ loop.revindex0 }} {# int #}
{{ loop.revindex }} {# int #}
{{ loop.first }} {# bool #}
{{ loop.last }} {# bool #}
{{ loop.length }} {# int #}
{{ loop.parent }} {# parent context #}
{% for name, age in other %}
{{ loop.parent.index }}
{% for foo, bar in friends %}
{{ loop.parent.index }}
{{ loop.parent.parent.index }}
{% endfor %}
{% endfor %}
{% endfor %}
{{ newvar }}
{% set newvar = 'value' %}
{% set myObj = {my: 'object'} %}
{% set myArr = ['my', 'array'] %}
{{ dump(myArr) }}
{{ '# Some markdown code
** with some bold text too **'|md }}
{% macro input(name, value, type, size) %}
<input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
{% endmacro %}
<div class="container">
<h1>Title</h1>
{% import _self as forms %}
<p>{{ forms.input('username') }}</p>
<p>Paragraph</p>
</div>
<script>
{% spaceless %}
var exampleJavascript = {
this: 'that',
foo: 'bar',
doit: function(){
console.log('yesss');
}
};
{% endspaceless %}
</script>
<style type="text/css">
{% spaceless %}
a.bg-primary:hover,
a.bg-primary:focus {
background-color: #286090;
}
.bg-success {
background-color: #dff0d8;
}
a.bg-success:hover,
a.bg-success:focus {
background-color: #c1e2b3;
}
{% endspaceless %}
</style>
<head>
{% scripts %}
{% styles %}
{% framework extras %}
</head>