of course the official way is to pass variables using
<flexy:toJavascript
javascript_varname="php_var_name">
<script type="text/javascript">
javascript_varname="the default";
</script>
</flexy:toJavascript>
So that templates can be tested independantly of the renderer..
(otherwise use XMLUrlRequest to fetch data)
But I guess there should be some way to write generated Javascript.. perhaps
<script type="text/javascript" flexy:code="{myjscode():h}">