is it possible to pass the foo token as an argument to inline javascript function
I feel like you're asking whether the HTML module can be given an embedded <script>
tag, in which a call is made, on which call is passed a $foo$ token. Do I have the spirit of your question right?
Assuming I do, it gets really confusing fast, to try and embed script into HTML modules. The HTML module will completely re-render it's contents whenever it receives a push from upstream (see the "Introduction to the advanced XML" page in Sideview Utils for an explanation of what this means).
Instead of making function calls from an HTML module though, it is much better to make a proper interface between the module system and your custom code, in the form of a CustomBehavior module. You then embed the CustomBehavior module into some appropriate point in the hierarchy, and you define the actual behavior in application.js (See the CustomBehavior docs in Sideview Utils). If you want it to do something when it receives a push, you implement onContextChange. If you want it to provide new tokens to downstream modules, you implement getModifiedContext. Those are the two most common methods overridden but there's no limit to the other weirder things you can do.
Also make sure you've read all the Sideview Utils docs and you have the latest version. Sometimes people go to the trouble of making a customBehavior to do something that can already be done using the Sideview modules.