Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add Attributes in haml

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 547
    Comment on it

    Hello Readers!
    In the previous Blog I have explained about HAML, now I am going to explain you that how we can add attributes in It. This syntax is much more similar to the HTML tags

    For Example:-  
          

      %a{:href => '#', :class => 'bar', :title => 'Bar'}Hello haml


    This syntax here explain the meaning of attributes here in this class name is defined with the notation :class => 'bar' :title =>'bar' is written with in the anchor tag body.

     

    :class and :id Attributes

    The :class and :id attributes is used in the form of array, whose elements will be joined by another attribute, The class attribute is used with the " " double quotes and the Id is used by using the underscore sign in between the double quotes.

    For Example:

     %div#bar
    	     %span#rice Hello Haml
    	     %input#2.cust-checkbox{:selected => "true", :type => "checkbox"}
    	     %label.cust-checkboxLabel{:for => "2"}
    	     %h1.otherclass#items haml attributes explaination


    These line of code complied in html language as:

      <div id="bar"></div>
    	    <span id="rice">Hello haml</span>
    	    <input type="checkbox" class="cust-checkbox" id="2" selected="true">
    	    <label class="cust-checkboxLabel" for="2">
    	    <h1 class="otherclass" id="items">haml attributes explaination</hl>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: