Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://api.cakephp.org/1.3/source-class-Helper.html#___formatAttribute" rel="nofollow">Checking the source code</a> indicates that there is no way to implement such tag as it's obvious that the format of attributes is <code>%s="%s"</code>.</p> <p>If you really need this I think the easiest way now is to provide your own customized <code>HtmlHelper</code> by extending the core <code>HtmlHelper</code>, and overwrite the <code>_formatAttribute</code> function:</p> <p><strong>Note: this is for CakePHP 1.3.x only and it's pretty messy as it can't specify <code>className</code> in the helpers array. CakePHP 2.x provides a cleaner way to overwrite default core helper with ease, but it's not what OP wanted so I'll not put it up here</strong></p> <ol> <li><p>Create <code>app/views/helpers/custom_html.php</code>:</p> <pre><code>&lt;?php App::import('Helper', 'Html'); class CustomHtmlHelper extends HtmlHelper { function __formatAttribute($key, $value, $escape = true) { if (in_array($key, array('async', 'defer'))) { return $key; } return parent::__formatAttribute($key, $value, $escape); } } </code></pre></li> <li><p>In your <code>app_controller.php</code> or whatever main controller that need this, use the <code>CustomHtmlHelper</code> by:</p> <pre><code>var $helpers = array('CustomHtml'); </code></pre></li> <li><p>And in your view, you can now start using <code>async</code> or <code>defer</code> tag. Feel free to extend this array if you see fit.</p> <pre><code>echo $this-&gt;CustomHtml-&gt;script('test', array('async' =&gt; 'async')); </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload