Questions tagged [haml]

HAML is a markup language that’s used to cleanly and simply describe the HTML of any web document without the use of inline code. It can be used as a standalone HTML generation tool or as a template rendering engine in a web framework such as Ruby on Rails or Ramaze. HAML templates are pre-compiled into plain HTML templates which is consumed by a client's web browser to render information sent by the server as a HTML web page.

HAML (HTML Abstraction Markup Language) is an indentation based, terse page description markup. It features among other things autoclosing of tags and convenient shorthands to set class and id attributes.


Example

page and its conversion :

erb

<div id='content'>
  <div class='left column'>
    <h2>Welcome to our site!</h2>
    <p><%= print_information %></p>
  </div>
  <div class="right column">
    <%= render :partial => "sidebar" %>
  </div>
</div>

HAML

#content
  .left.column
    %h2 Welcome to our site!
    %p= print_information
  .right.column
    = render :partial => "sidebar"

Where to start:

  1. Getting Started Tutorial

  2. Html2haml converter

3540 questions
1
vote
1 answer

Rendering a dropdown Menu in Backbone

I am new to Backbone and am trying to stumble my way through it. At the moment I have a view that renders a json hash into a dropdown menu. When I inspect the element in the browser I can actual view the UL element with all of the JSON rendered…
mrtriangle
  • 542
  • 11
  • 28
1
vote
2 answers

Parsing atom/rss feed containing multiple tags with Haml on RoR

So, firstly, here's an Atom feed snippet which I am trying to parse: // http://somelink.com/atom Title Here
Parag
  • 963
  • 2
  • 10
  • 27
1
vote
1 answer

Help me understand dynamic layouts in Sinatra

Help me understand this; I'm learning Sinatra (and Rails for that matter, er, and Ruby). Say I'm doing a search app. The search form is laid out in one div, and the results will be laid out in another. The search form is rendered into the div by a…
thermans
  • 1,169
  • 2
  • 14
  • 24
1
vote
1 answer

How to convert Rails whole application in erb to haml

I have one Rails application and all files are in erb format. Is there any quick way to convert whole application's erb file to haml.. without any conflict. And also would like to know for the Reverse.. Thanks in advance. :)
user3814943
1
vote
1 answer

HAML iterate over collection - how to wrap groups of child elements in unique parents?

I have an ActiveRecord collection which consists of a number of elements that each have a different type, (simplified names/variables) for example (if it were converted to a serializable_hash): [ {"id" => 1, "type" => "book", "title" => "title…
waffl
  • 5,179
  • 10
  • 73
  • 123
1
vote
1 answer

Building option list with haml

I'm trying to create a select control with options using HAML in Sinatra. There should be an option for each value in my @ages array. I have verified that @ages is actually in the view by printing it out. My select tag however does not show these…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
1
vote
0 answers

How to implement partials using HAML

We are testing HAML and SASS on a recent project to speed up our development flow. We built the static front-end, and from here, will be integrating the source into a Wordpress build. HAML isn't going to be used in the WP integration; we only used…
Brandon
  • 11
  • 1
1
vote
1 answer

How to have a 'click' event on an element inserted by jquery?

I would like to toggle an on | off element so that it bolds the currently selected option and provides a link to the other option. A fairly common pattern. I got the row shading itself working, however presenting the links (or text) to turn it on…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
1
vote
1 answer

Ruby on Rails simple_form prepend $ before input with custom label

I'm trying to prepend a $ in front of one of my fields and I was able to successfully do so, but without a custom label. This is the code that works: = f.input :amount do $ = f.input_field :amount, :label => false, :hint => false, :wrapper…
apardes
  • 4,272
  • 7
  • 40
  • 66
1
vote
1 answer

How should i pass $scope value to function in haml template

I am using haml templates with angular js. While template rendering i want to create a function call on div using ng-click. It is working fine without parameter but when I am passing a parameter to function it behaving like as below for two…
Swapnil Patil
  • 971
  • 2
  • 18
  • 41
1
vote
1 answer

Assign value using loop in HAML

My question is kind of a general ruby question, but I'm using HAML so I'll ask it in that context. I'm using twitter bootstrap and I want to iterate over a list to populate a popover's content I have: %div =link_to link_name, link, ...,…
1
vote
1 answer

HAML each loop add additional classes to nth elements

I'm trying to build a large gallery with different sized tiles and was wondering how can I accomplish with a HAML each loop the following result? .box.box-large %img .box.box-medium %img .box %img .box %img .box.box-large …
Cos
  • 127
  • 2
  • 11
1
vote
1 answer

Rails 4.0.1 Creating Database Record from link_to

I am trying to create a new record when a user pushes a button. The page seems to be refreshing but no records are being created %tbody - page_list.each do |page| %tr %td.text-center=image_tag…
Boss Nass
  • 3,384
  • 9
  • 48
  • 90
1
vote
4 answers

Switching between tabs does not work with JQuery

So I have this simple menu in haml that is meant to be tabbed .monthly_tab#selected Monthly .yearly_tab#notselected Yearly And this is the JQuery code to switch between tabs. It does not work completely correctly. I can switch…
Helena
  • 921
  • 1
  • 15
  • 24
1
vote
1 answer

Creating headers for a list in haml

I have the following piece of haml code %dt= 'Properties' %dd{title: 'Properties'} - config[:Properties].each do |key, values| %p %em %b= t('.Key') = key %em %b= t('.Value') = values here rather than…
kauschan
  • 446
  • 2
  • 8
  • 21
1 2 3
99
100