HAML provides the ability to use interpolation anywhere within the  
javascript literal. For example:

:javascript
    window.addEvent('domready', function(){
        console.log("#...@some_string}");
    });

set @some_string on the controller and you'll be able to get what you  
need.

It's definitely not great for blocks and if/then statements, but it  
should provide for at least a bit of dynamic content within your  
javascript code. I'd recommend against all that though and doing  
things through non-obstrusive methods.

On Nov 9, 2009, at 8:43 PM, Jon Hancock wrote:

>
> Here's my problem:  I'm using haml templates.  Haml has a nice tag for
> embedding javascript.  So I can have a template that look like so:
>
> %h1 my page
> #someDiv
> :javascript
>    window.addEvent('domready', function(){
>        // do some cool stuff
>    });
>
> This allows me quite a bit of freedom.  However, what do I do when the
> javascript needs some parameters, for example some variable from my
> controller?  I can't do this as the haml javascript embedding is
> literal.
>
> I have been thinking about a merb helper so I could write the above
> as:
>
> %h1 my page
> #someDiv
> = javascriptHelper
>    window.addEvent('domready', function(){
>        // do some cool stuff WITH PARAM PARSING ON THIS CONTENT
>    });
>
> But I don't see how this can be done.  Any ideas on how to make this
> easy?  The current helpers I'm writing are horrific javascript string
> concatenation nightmares.
>
> thanks, Jon
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to