Helperを使うといいと思います。
Helperの場合は引数を明示的に渡したり、
関係のあるjsの処理をclassにまとめることができるので管理もしやすいかと思います。
php
1class HogeScriptHelper extends AppHelper {
2
3 public function hogeText($selector) {
4 $this->_View->Html->scriptStart(array('inline' => false));
5 echo <<<SCRIPT
6$('{$selector}').text('hoge!');
7SCRIPT;
8 $this->_View->Html->scriptEnd();
9 }
10}
別の書き方
php
1class HogeScriptHelper extends AppHelper {
2
3 // 使用するHelperの宣言
4 public $helpers = array('Html');
5
6 public function hogeText($selector) {
7 $this->Html->scriptStart(array('inline' => false));
8 echo <<<SCRIPT
9$('{$selector}').text('hoge!');
10SCRIPT;
11 $this->Html->scriptEnd();
12 }
13}
上記のHelperを作成してViewにて
php
1$this->HogeScript->hogeText('.hoge');