Jamal Helper

Published on and tagged with cakephp  helper  jamal  javascript

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 :)

5 comments baked

  • Anonymous

    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.

  • cakebaker

    @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.

  • MP:Schorsch

    a couple of days ago i found this projekt hosted on google.

    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.

  • Timo Derstappen

    thanks daniel. i promise to get some more documentation out there soon :)

  • cakebaker

    @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 ;-)

  • bahis siteleri


    […] What host are you using? Can I am getting your associate link on your host? I want site loaded up as fast as yours lol[…]

  • bahis siteleri

    Look there for more:

    […]you make blogging glance[…]

  • sportotobet

    …Take a look for more Information on that topic

    […] What host are you the use of? Can I am getting your associate link for your host? I desire my website loaded up as fast as yours lol[…]

  • Google


    Here is a good Blog You might Uncover Fascinating that we encourage you to visit.

  • mp3 songs

    mp3 songs

    […]here are some links to web pages that we link to mainly because we feel they are really worth visiting[…]

  • Google


    Check below, are some totally unrelated sites to ours, having said that, they are most trustworthy sources that we use.

  • aflampornhd


    […]check beneath, are some totally unrelated internet websites to ours, even so, they are most trustworthy sources that we use[…]

  • adult tube websites

    adult tube websites

    […]Wonderful story, reckoned we could combine several unrelated data, nonetheless seriously really worth taking a look, whoa did one discover about Mid East has got extra problerms as well […]

  • chicago house dj

    chicago house dj

    […]The facts mentioned within the post are a few of the ideal available […]

  • real estate inspection

    real estate inspection

    […]check below, are some totally unrelated web-sites to ours, having said that, they are most trustworthy sources that we use[…]

  • hilo home inspections

    hilo home inspections

    […]please stop by the internet sites we comply with, such as this a single, because it represents our picks from the web[…]

  • Apple


    […]here are some links to web pages that we link to simply because we believe they’re really worth visiting[…]

  • sexy and elegant lingerie

    sexy and elegant lingerie

    […]The data mentioned within the report are a number of the ideal obtainable […]

  • hawaii building inspectors

    hawaii building inspectors

    […]just beneath, are several absolutely not connected internet sites to ours, nevertheless, they’re surely worth going over[…]

  • video production services

    video production services

    […]The details mentioned in the post are a number of the top accessible […]

Bake a comment

(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License