In my JavaScript (using jQuery) there are a whole set of PHP variables to which I need access. While I’ve got it working by just producing the JavaScript file as a view, and then using renderPartial() to echo the JavaScript inside the main view.
However, this is obviously not very elegant, so I would like to know the ‘Yii’ way of doing it. I’ve been looking at the Assets Manager but that seems to be for static JavaScript files – you can’t include PHP in there (unless I’m wrong).
Is there another way of doing it?
You may consider registerScript. In my opinion, it is better since there is a param named $position, which can help you control the process output of render().