3.10.2. General Helpers

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.

3.10.2.1. anchor

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.)

3.10.2.2. base

Helper for <base> tags.

{{= base (
    '/base'                         // (string) href
) }}
<base href="/base" />

3.10.2.3. dl

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>

3.10.2.4. image

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" />

3.10.2.5. items

Helper for a series of <li> tags.

{{= items ([                        // (array) list items
    'foo',
    'bar',
    'baz'
]) }}
<li>foo</li>
<li>bar</li>
<li>baz</li>

3.10.2.6. link

Helper for a <link> tag.

{{= link ([                         // (array) attributes
    'rel' => 'prev',
    'href' => '/path/to/prev',
]) }}
<link rel="prev" href="/path/to/prev" />

3.10.2.7. linkStylesheet

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" />

3.10.2.8. meta

Helper for a <meta> tag.

{{= meta ([                         // (array) attributes
    'charset' => 'utf-8'
]) }}
<meta charset="utf-8">

3.10.2.9. metaHttp

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">

3.10.2.10. metaName

Helper for a <meta name> tag.

{{= metaHttp (
    'author',                       // (string) name attribute
    'Qiq for PHP'                   // (string) content attribute
) }}
<meta name="author" content="Qiq for PHP">

3.10.2.11. ol

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>

3.10.2.12. script

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>

3.10.2.13. ul

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>