Hello,
This is my first attempt to do something with Haml.  So I thought I
will run it by more experienced members of this group.  This is an ERB
form from Insoshi Social Network code base, called new.html.erb.  I am
using this as a test case to learn Haml.


<%- column_div :type => :primary do -%>
  <h2>Sign in</h2>

  <% form_tag session_path do -%>
    <div id="standard">
        <div class="form_row">
          <label for="email">Email address</label>
          <%= text_field_tag 'email', params[:email],
                             :maxlength => Person::MAX_EMAIL  %>
        </div>
        <%= set_focus_to "email" %>

        <div class="form_row">
          <label for="password">Password</label>
          <%= password_field_tag 'password', params[:password],
                                 :maxlength => Person::MAX_PASSWORD %>
        </div>
    </div>
    <div class="form_row" id="openid">
      <label for="openid_url">OpenID</label>
      <%= text_field_tag "openid_url" %>
    </div>

    <div class="form_row">
      <label for="remember_me" class="checkbox">Remember me:</label>
      <%= check_box_tag 'remember_me', '1', true, :class => "checkbox"
%>
    </div>

    <div class="form_row">
      <%= submit_tag 'Sign in', :class => "button" %>
    </div>

    <div style="text-align: center; font-size: 12px; padding: 10px;">
      <%= link_to "or Sign up", signup_path %> <br />
      <%- if global_prefs.can_send_email? -%>
        <%= link_to "I forgot my password!",
new_password_reminder_path %> ::
      <%- end -%>
        <span id="noscript" style="display:none;">
            <span id="openid_link"><a href="#" onclick="show_openid();
return false;">Login using OpenID</a></span>
            <span id="standard_link"><a href="#" onclick="show_standard
(); return false;">Back to Regular Login</a></span>
        </span>

    </div>
  <% end -%>
<%- end -%>

<script type='text/javascript'>
$(document).ready(function() {
  show_openid = function() {
      $('#openid').show();
      $('#standard').hide();
      $('#openid_link').hide();
      $('#standard_link').show();
      createCookie('use_openid', 1, 30);
      $('#openid_url').value = 'http://';
  }

  ..... Javascript code deleted to keep this short ...

  function eraseCookie(name) {
      createCookie(name,"",-1);
  }
})
</script>

Here is corresponding new.html.haml file:

- column_div :type => :primary do
  %h2 Sign In
    - form_tag session_path do
      #standard
        .form_row
          %label{:for => "email"} Email address
          = text_field_tag 'email', nil, :maxlength =>
Person::MAX_EMAIL
          = set_focus_to 'email'
        .form_row
          %label{:for => "password"} Password
          = password_field_tag 'password', params
[:password], :maxlength => Person::MAX_PASSWORD
      #openid.form_row
        %label{:for => 'openid_url'} OpenID
        = text_field_tag 'openid_url'
      .form_row
        %label.checkbox{:for => 'remember_me'} Remember me:
        = check_box_tag 'remember_me', '1', true, :class => "checkbox"
      .form_row
        = submit_tag 'Sign in', :class => "button"

I have several questions:

1.  Am I doing this right?
2.  How do I translate the following code from new.html.erb to
corresponding new.html.haml?

    <div style="text-align: center; font-size: 12px; padding: 10px;">
      <%= link_to "or Sign up", signup_path %> <br />
      <%- if global_prefs.can_send_email? -%>
        <%= link_to "I forgot my password!",
new_password_reminder_path %> ::
      <%- end -%>
        <span id="noscript" style="display:none;">
            <span id="openid_link"><a href="#" onclick="show_openid();
return false;">Login using OpenID</a></span>
            <span id="standard_link"><a href="#" onclick="show_standard
(); return false;">Back to Regular Login</a></span>
        </span>

    </div>

I am not sure how to deal with style attribute and inline javascript
code, e.g., onclick="show_openid()..."

3. How do you show inline Javascript code in a haml file?  For
example, the above new.html.erb file contains the following code:

<script type='text/javascript'>
$(document).ready(function() {
   ......
})
</script>

How is this represented in Haml?

Thanks in advance for your time.

Bharat


--~--~---------~--~----~------------~-------~--~----~
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