In the last few days I experimented again with the Javascript MVC framework Jamal. To make its usage a bit easier I wrote a simple helper (you can find it in the downloads section).
As usual, you have to add the helper to the $helpers array of your controller(s) before you can use it:
var $helpers = array('Jamal');
The helper provides two public methods: link() and set().
The link() method is used in the head section of the layout to include all Jamal-related files.
echo $jamal->link();
If DEBUG is greater than 0, it creates something like:
<script type="text/javascript" src="/js/src/jamal.js"></script> <script type="text/javascript" src="/js/src/models/example.js"></script> <script type="text/javascript" src="/js/src/plugins/metadata.js"></script> <script type="text/javascript" src="/js/src/controllers/examples_controller.js"></script> <script type="text/javascript" src="/js/src/views/examples.js"></script> <script type="text/javascript" src="/js/src/startup.js"></script>
As soon as you switch DEBUG to 0, it will include the packed version of your scripts (you have to pack them “manually” with the Ant script that comes with Jamal):
<script type="text/javascript" src="/js/dist/jamal_packed.js"></script> <script type="text/javascript" src="/js/dist/startup.js"></script>
The second method, set(), is used to specify which (Javascript) controller action is executed when the respective view is loaded. So in the view you will do something like:
$jamal->set('MyController', 'myAction');
Additionally, you have to add the variable $jamal_for_layout to the body tag of your layout:
<body <?php echo $jamal_for_layout; ?>>
This will then generate the following code for Jamal:
>body class="jamal {controller:'MyController',action:'myAction',debug:false}">
Happy baking with Jamal :)

Thanks for pointing me to Jamal, it looks wonderful.
Wish there were a little more doc/examples but I’m loving what I see.
I could see the ant stuff turning some people off unfortunately — maybe there can be an alternative path to packing.
@Anonymous: Yes, it is a nice idea, even though it is sometimes a bit difficult to decide whether you should put something to the model, the view or the controller ;-)
It is possible that the Ant script turns some people off, but I think it would be easy to write a shell script which does the same work.
a couple of days ago i found this projekt hosted on google.
http://code.google.com/p/jscsscomp/
this is a php based css and js compressor which i thought could be used with the debug switch. It can compress multiple js into one and cache the result. But I haven“t had the time to try it out.
thanks daniel. i promise to get some more documentation out there soon :)
@MP:Schorsch: Thanks for the link. I have to try it out when I have some time.
@Timo: Cool, a more advanced example would be really helpful ;-)