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
0 answers

Simple html/haml form submit button - Post doesn't work

I have a form from a model where I am trying to update multiple records with one submit. I couldn't get it working Here is the haml code with slight ruby in it. .container#questions .col-md-8 - @questions.each do |q| - ans =…
codeObserver
  • 6,521
  • 16
  • 76
  • 121
1
vote
1 answer

Where can I use HAML in Octopress?

So, according to the Octopress official page, it has HAML integration plugin. Naturally, I gave it a try. I backed up my source/_includes/custom/head.html file, converted it to haml and saved it as source/_includes/custom/head.haml. It gave me an…
art-solopov
  • 4,289
  • 3
  • 25
  • 44
1
vote
0 answers

Rails - How to create a form_for to update a list of records?

I have a team, and the team has many players. I want to show the player's names in a form and allow the user to update these names. How can i solve this problem? I am new in rails.The code is in .html.haml, and it gives me an error when i add the…
1
vote
1 answer

How to put several attributes of a record with one Haml line

In erb we can have <%= @user.name %>, <%= @user.email %> to put name and email in one line both on the resulting page and in the code. What is the best way to do the same with Haml? =@user.name << ', ' << @user.email and ="#{@user.name},…
1
vote
1 answer

How correctly use haml template in knockoutjs foreach binding?

I can't get div element ".some" with text "Some" with such haml template and knockout foreach binding. Thus, div element ".steph" forms correctly. .steps{data:{bind: "foreach: steps"}} .step .steph.editable.act{data:{bind: "text: name"}} …
Voltrun
  • 77
  • 7
1
vote
2 answers

How do I make Rack::Reloader re-load changes to haml files?

My jruby rack sinatra compass haml app correctly reloads changes to *.rb files, but does not detect changes to *.haml files. Is this compass doing some caching or a limitation of Rack::Reloader? Any pointers to how to fix?
Ben Hogan
  • 149
  • 1
  • 8
1
vote
2 answers

Rails 3 Beta 2, Haml, Nested Layouts and LocalJumpError

Alright, I'm trying to create an app with nested templates. I'm using Rails 3 Beta 2 and Haml. I've poked around and I've decided to take the clearest approach and have structured my templates like so: # application.html.haml !!! %body %h1…
CJ Bryan
  • 178
  • 9
1
vote
2 answers

HAML with forms

I have this form: = simple_form_for :login, url: sessions_path, method: :post, role: "form", class: "form-horizontal" do |f| = f.input :email = f.input :password = f.input :remember_me, as: :boolean, label: false, inline_label: "Stay…
mtkcs
  • 1,696
  • 14
  • 27
1
vote
2 answers

ruby sinatra base get '/foo/bar' public directory

GITHUB: https://github.com/coasterb/foo_bar_stackoverflow I cannot access the style sheet in my public directory with my '/foo/bar' route. I thought it was an issue where I didn't define the public_folder, but it isn't. require 'sinatra' require…
user2446058
  • 146
  • 10
1
vote
0 answers

onclick event on checkbox in haml/rails

I want to implement realtime events (google analytics) on our filter engine. This is my code: %fieldset .checkbox %input{type: "checkbox", value: ".range-1", :onclick=>"_gaq.push(['_trackEvent', 'Price', 'Range 100-200', 'Yep']);" } This is…
Remco
  • 681
  • 1
  • 6
  • 20
1
vote
2 answers

How to change color of HAML tags in NetBeans?

I use Aloha theme in NetBeans 6.8, everything looks cool except these blue tags in HAML files, which are unreadable. How to find a place where this blue color could be changed? P.S. I use that HAML plugin which seems to be unsupported and lacks…
1
vote
2 answers

Hoes does the HAML compiler know when a line has ended?

The HAML has a very good advantage to ERB, this advantage is not having closing tags. ERB <%= item.title %> HAML %strong= item.title However, I was always taught that HTML had closing tags so that it knew when to stop doing…
Alexander Craggs
  • 7,874
  • 4
  • 24
  • 46
1
vote
0 answers

Pure CSS Modal in SASS

I'm trying to recreate this pure CSS modal in SASS for my Rails app: http://codepen.io/maccadb7/pen/nbHEg Here is my SASS // // Variables // ---------------------- $gray: #333 $gray-light: #aaa $gray-lighter: #eee $space: 40px $blue:…
apardes
  • 4,272
  • 7
  • 40
  • 66
1
vote
1 answer

How to write haml in case of using only opening html tag in if&else constrruction

I have perfect working ERB partial, it look's like: <% if error_tag.present? %>
<% else %>
<% end %>
master_x
  • 13
  • 2
1
vote
1 answer

HAML add href if

Rails 4 + HAML. Is there any way to consolidate this into one line? - if current_page?(controller: 'root', action: 'sign_up') %a Sign Up - else %a{href: program_sign_up_path} Sign Up The reason is that if the link has an href, it appears to…
David A
  • 717
  • 1
  • 8
  • 18