All helpers automatically apply appropriate escaping. This means you can use
{{= ... }}
to output them. If you use {{h ... }}
et al., you will end up
double-escaping the output.
You can also address the helpers as methods on $this
in PHP template code.
Helper for <a>
tags.
{{= anchor (
'http://qiqphp.com', // (string) href
'Qiq Project', // (string) text
[ // (array) optional attributes
'id' => 'qiq-link'
]
) }}
<a href="http://qiqphp.com" id="qiq-link">Qiq for PHP</a>
To output the anchor text without escaping, use the pseudo-attribute _raw
:
{{= anchor (
'http://qiqphp.com', // (string) href
'<em>qiq Project</em>', // (string) text
[ // (array) optional attributes
'id' => 'qiq-link'
'_raw' => true
]
) }}
<a href="http://qiqphp.com" id="qiq-link"><em>Qiq for PHP</em></a>
(The href and attributes will still be escaped properly.)
Helper for <base>
tags.
{{= base (
'/base' // (string) href
) }}
<base href="/base" />
Helper for <dl>
tags with <dt>
/<dd>
items.
{{= dl (
[ // (array) dt keys and dd values
'foo' => 'Foo Def',
'bar' => [
'Bar Def A',
'Bar Def B',
'Bar Def C',
],
'baz' => 'Baz Def',
],
[ // (array) optional attributes
'id' => 'test'
],
) }}
<dl id="test">
<dt>foo</dt>
<dd>Foo Def</dd>
<dt>bar</dt>
<dd>Bar Def A</dd>
<dd>Bar Def B</dd>
<dd>Bar Def C</dd>
<dt>baz</dt>
<dd>Baz Def</dd>
</dl>
Helper for <img>
tags.
{{= image (
'/images/hello.jpg', // (string) image href src
[ // (array) optional attributes
'id' => 'image-id'
]
) }}
<!-- if alt is not specified, uses the basename of the image href -->
<img src="/images/hello.jpg" alt="hello" id="image-id" />
Helper for a series of <li>
tags.
{{= items ([ // (array) list items
'foo',
'bar',
'baz'
]) }}
<li>foo</li>
<li>bar</li>
<li>baz</li>
Helper for a <link>
tag.
{{= link ([ // (array) attributes
'rel' => 'prev',
'href' => '/path/to/prev',
]) }}
<link rel="prev" href="/path/to/prev" />
Helper for a <link>
stylesheet tag.
{{= linkStylesheet (
'/css/print.css', // (string) the stylesheet href
[ // (array) optional attributes
'media' => 'print',
]
) }}
<link rel="stylesheet" href="/css/print.css" type="text/css" media="print" />
Helper for a <meta>
tag.
{{= meta ([ // (array) attributes
'charset' => 'utf-8'
]) }}
<meta charset="utf-8">
Helper for a <meta http-equiv>
tag.
{{= metaHttp (
'Location', // (string) http-equiv attribute
'/redirect/to/here' // (string) content attribute
) }}
<meta http-equiv="Location" content="/redirect/to/here">
Helper for a <meta name>
tag.
{{= metaHttp (
'author', // (string) name attribute
'Qiq for PHP' // (string) content attribute
) }}
<meta name="author" content="Qiq for PHP">
Helper for <ol>
tags with <li>
items.
{{= ol (
[ // (array) list items
'foo',
'bar',
'baz'
],
[ // (array) optional attributes
'id' => 'foo-list'
]
) }}
<ol id="foo-list">
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ol>
Helper for a <script>
tag.
{{= script (
'/js/functions.js', // (string) src attribute
[ // (array) other attributes
'async' => true
]
) }}
<script src="/js/functions.js" type="text/javascript" async></script>
Helper for <ul>
tags with <li>
items.
{{= ul (
[ // (array) list items
'foo',
'bar',
'baz'
],
[ // (array) optional attributes
'id' => 'foo-list'
]
) }}
<ul id="foo-list">
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>