For Javascript, you're looking for filters. These allow you to use 
non-Haml text (and indentation) in a Haml template. In Haml 1.8.2, you'd 
use the :plain filter, which just takes plain text:

%script{:type => "text/javascript"}
  :plain

    $("#beta_signup_email").click(function() {
      this.value = "";
      this.style["text-align"]="left";
    });


In the master branch, you can use the :javascript filter instead, which 
also adds script and CDATA tags:

:javascript

  $("#beta_signup_email").click(function() {
    this.value = "";
    this.style["text-align"]="left";
  });

For long blocks of Ruby code, it's recommended that you move it into a 
helper (back_to_account_link or something) so you can keep your views 
more clean. If you need to, though, you can use | at the end of each 
line to make a multiline block:

= link_to "Back", admin_account_url(@account),   |
       :class => "icon back", :accesskey => "b", |
       :title => "Back to Account (ctrl-b)"      |


- Nathan

chris wrote:
> I would like to insert a small amount of javascript onto a page, and
> the only way that I can figure out how to do so is to make sure it is
> all on one line ex
>
> %script{:type => "text/javascript"}
>   $("#beta_signup_email").click(function() {this.value="";
> this.style["text-align"]="left";});
>
> Is there a way around this?
>
> This also relates to an issue that I have had with rails code in a
> view.
>
> = link_to "Back", admin_account_url(@account), :class => "icon
> back", :accesskey => "b", :title => "Back to Account (ctrl-b)"
>
> Sometimes it would be nice to pretty things up like in erb to:
>
> = link_to "Back", admin_account_url(@account),
>        :class => "icon back", :accesskey => "b",
>        :title => "Back to Account (ctrl-b)"
>
> Is this doable?
>
> Thanks for the help.
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" 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/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to