事象
- CakePHP 2.3.9において
$this->Html->css(array('style'), null, array('inline' => false));
で指定のCSSが繰り返した分だけ<head>に出現する。 -
$this->Html->script(array('script'), array('inline' => false));
で指定のJSは重複しないのでCSSも同様の動作を期待していたものの異なる挙動だった。
コード例
- elementで利用するctp内で定義。例えば下記のように3回出現すると...
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
- (期待)HTMLでは重複のない状態で出力される事を期待していた。
<link rel="stylesheet" type="text/css" href="/css/style.css" />
- (実際)HTMLで繰り返し出力された。
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
ISSUEで報告済みの事象だった。
-
https://github.com/cakephp/cakephp/pull/3653
2015/02/19時点で入手可能なCakePHP 2.6.1では重複させない事も可能になっている様子。