Directives
Textwire directives provide control over your templates through commands that begin with @. These directives enable you to conditionally display content, iterate over data, create reusable layouts, and build modular components. Each directive serves a specific purpose in the template rendering process, allowing you to write dynamic and maintainable templates without mixing complex logic into your presentation layer.
- @if
@if(x == 1) - @use
@use("layouts/main") - @insert
@insert("title", "Home") - @reserve
@reserve("title") - @for
@for(i = 0; i < 2; i++) - @each
@each(name in names) - @component
@component("components/post-card")@end - @slot
@slot('footer') - @pass
@pass('footer')@end - @passif
@passif(true, 'footer')@end - @dump
@dump(users, page)
Reserved Names
Directive names are reserved keywords. If you need to use one of them as plain text, for example in an email address, escape it with a backslash. Read more about escaping.
For example, me@username.com results in the error syntax error: expected '(' but found 'rname.com', because @use is a reserved directive. Escape it like this: me\@username.com to get me@username.com.
