ClientScript registerScriptFile Question


I´m new to using Yii but loving it already! Theres one thing regarding javascript I need clarification on…

I have stored my Javascripts in JS-files in a folder on the same level as CSS and Images. Can I call a JS-file from this folder and have it´s contents inserted into the <head> part of my layout-file when the layout is rendered?

In my controller file I use:

Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . "/js/myfile.js");

This work fine but it creates a reference to the JS file, like:



<script type="text/javascript" src="/js/myfile.js"></script>


I would like the JS to be included in the HTML file, like:



<script type="text/javascript">

function foo() {





Is this possible? I would also like to be able to do this with CSS.

Thanks in advance!






Ahh, ofcourse. Feels very obvious now =)