Skip to content

Instantly share code, notes, and snippets.

@tai-sho
Last active August 29, 2015 13:58
Show Gist options
  • Save tai-sho/9987732 to your computer and use it in GitHub Desktop.
Save tai-sho/9987732 to your computer and use it in GitHub Desktop.
CakePHPが出力するHTMLからスペースやタブを削除する。
<?php
App::uses('Helper', 'View');
class AppHelper extends Helper {
/**
* CakeがHTMLを出力する際に生成される無駄なタブを削除する。
* @see Helper::afterLayout()
*/
public function afterLayout($layoutFile) {
parent::afterLayout($layoutFile);
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
//出力するソースのタブを削除する
if ($this->_View){
$this->_View->output = mb_ereg_replace(' *\t *', '', $this->_View->output);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment