utility function to output inline JavaScript

This commit is contained in:
Evan Prodromou 2009-12-04 13:39:51 -05:00
parent d2b42577de
commit 2c07d4a530

View File

@ -360,6 +360,25 @@ class HTMLOutputter extends XMLOutputter
' '); ' ');
} }
/**
* output a script (almost always javascript) tag with inline
* code.
*
* @param string $code relative or absolute script path
* @param string $type 'type' attribute value of the tag
*
* @return void
*/
function inlineScript($code, $type='text/javascript')
{
$this->elementStart('script', array('type' => $type));
$this->raw('/*<![CDATA[*/ '); // XHTML compat for Safari
$this->raw($code);
$this->raw(' /*]]>*/'); // XHTML compat for Safari
$this->elementEnd('script');
}
/** /**
* output a css link * output a css link
* *
@ -414,7 +433,6 @@ class HTMLOutputter extends XMLOutputter
} }
} }
/** /**
* Internal script to autofocus the given element on page onload. * Internal script to autofocus the given element on page onload.
* *