You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ "apple,banana,cherry"|split(",")|join(" and ") }}
146
+
{{ "Hello" ~ " " ~ "World" }}
147
+
```
148
+
149
+
### **Array Operations**
150
+
151
+
```php
152
+
{% for item in items|sort %}
153
+
{{ item }}
76
154
{% endfor %}
155
+
156
+
{{ messages[-1]['content'] }} {# Last message #}
157
+
{{ array|length }} {# Array length #}
77
158
```
78
159
79
-
### Variable Filters
160
+
### **Set Statements**
80
161
81
-
```js
82
-
{{ "Hello World!"|lower }}
162
+
```php
163
+
{% set greeting = "Hello, " ~ user.name %}
164
+
{{ greeting }}
165
+
166
+
{% set user_info %}
167
+
Name: {{ user.name }}
168
+
Email: {{ user.email }}
169
+
{% endset %}
170
+
{{ user_info|indent(2) }}
83
171
```
84
172
85
-
##Comprehensive Feature Support
173
+
### **Filter Blocks**
86
174
87
-
Jinja PHP is designed to be robust and feature-rich, offering support for a wide range of functionalities beyond the
88
-
basics of templating. This includes handling exceptions, using default string methods like `strip()` or `upper()`,
89
-
working with dictionaries, and much more. If there's a feature you need that isn't currently implemented in Jinja PHP,
90
-
we encourage you to [request it](https://github.com/codewithkyrian/jinja-php/issues/new). Additionally, if you're
91
-
proficient with PHP and understand the internals of templating engines, consider contributing to the project by
92
-
submitting a pull request with your proposed feature.
175
+
```php
176
+
{% filter upper %}
177
+
This text will be uppercase
178
+
{% endfilter %}
179
+
```
93
180
94
-
## Testing
181
+
### **Comments**
182
+
183
+
```php
184
+
{# This is a comment that won't appear in output #}
185
+
{{ variable }} {# Inline comment #}
186
+
```
187
+
188
+
## Advanced Usage
189
+
190
+
### **Error Handling**
191
+
192
+
```php
193
+
{% if user.role == 'admin' %}
194
+
Admin panel
195
+
{% else %}
196
+
{{ raise_exception('Access denied') }}
197
+
{% endif %}
198
+
```
95
199
96
-
Jinja PHP comes with a suite of tests to ensure functionality remains consistent and reliable. To run the tests:
200
+
### **Complex Expressions**
97
201
202
+
```php
203
+
{{ (user.isActive and user.hasPermission) or user.isAdmin }}
204
+
{{ messages|length > 0 and messages[-1].role == 'user' }}
205
+
{{ "Hello" if user.name else "Guest" }}
98
206
```
207
+
208
+
## Testing
209
+
210
+
Jinja PHP comes with a comprehensive test suite to ensure functionality remains consistent and reliable. To run the tests:
211
+
212
+
```shell
99
213
composer test
100
214
```
101
215
216
+
The test suite includes:
217
+
- Unit tests for all language features
218
+
- End-to-end template processing tests
219
+
- Error handling and edge case tests
220
+
221
+
## Performance
222
+
223
+
Jinja PHP is designed for performance with:
224
+
- Zero external dependencies
225
+
- Efficient tokenization and parsing
226
+
- Optimized runtime execution
227
+
- Memory-conscious design
228
+
229
+
## Contributing
230
+
231
+
Jinja PHP is designed to be robust and feature-rich, offering support for a wide range of functionalities. If there's a feature you need that isn't currently implemented, we encourage you to [request it](https://github.com/codewithkyrian/jinja-php/issues/new). Additionally, if you're proficient with PHP and understand the internals of templating engines, consider contributing to the project by submitting a pull request with your proposed feature.
0 commit comments