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

Undefined local variable of method on partial. Flash notice

i'm trying to use growlflash and set up everything according to the docs. https://github.com/estum/growlyflash I have this line inside of a rendered partial.html.haml #header_message = growlyflash_static_notices And that partial is loaded…
TuxedoTomson
  • 483
  • 4
  • 16
1
vote
2 answers

how do put %span inside rails link_to in haml

font awesome inside link_to helper with haml how should I do? i have this code .link_header {link_to_ledger(current_ledger) span.icon-flag } help please
1
vote
1 answer

fullcalendar set an id it's not working

Hello I have the following haml javascript code to render a fullcalendar: %script(type="text/javascript") $(document).ready(function (){ $('#calendar').fullCalendar({ defaultView: 'agendaWeek', editable: false, eventLimit: true, events:…
Jean
  • 5,201
  • 11
  • 51
  • 87
1
vote
1 answer

inject values into javascript using haml on ruby on rails

I have the following loop :javascript $(document).ready(function() { $('#calendar').fullCalendar({ defaultDate: '2014-09-12', editable: false, eventLimit: true, events: [ { -…
Jean
  • 5,201
  • 11
  • 51
  • 87
1
vote
1 answer

pycharm code completion / syntax highlighting for django in haml files

I just tried to use HAML in my django project, which works fine^^ But while writing beautiful HAML code PyCharm refuse to offer any code completion or syntax highlighting for django template tags like in HTML files. Do I need to configure PyCharm…
Jimmy Foobar
  • 191
  • 1
  • 8
1
vote
1 answer

Confused about Bootstrap Non-responsive grid system

I'm trying to build a non-responsive form in bootstrap. I've followed the instructions on the bootstrap site here But instead of getting something like this, I'm getting this instead. Can someone explain what's going wrong? My understanding is…
Sri
  • 35
  • 5
1
vote
2 answers

Error: Class 'Haml' not found... trying to use Haml (Kohaml) with Kohana

Can't for the life of me figure out what I'm doing wrong... Downloaded Kohaml from http://github.com/transphorm/kohaml Dropped it into modules/kohaml # My Bootstrap reference 'kohaml' => MODPATH.'kohaml', // kohaml Keep getting this…
Serhiy
  • 2,505
  • 3
  • 33
  • 49
1
vote
1 answer

Why does undefined method `-@' for nil:NilClass mean (haml)?

I have this rails view partial and I just can't see the issue: %span{class: "show_hide #{show_hide}"} --------------------- = first_field_focus --------------------- - if first_field_focus == "1" - puts '++++++++++++' - puts 'y' …
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
1
vote
1 answer

Rails views and nill classes

I'm outputting the user's First+Last name by using: =current_user.try(:first_name)+" "+current_user.try(:last_name) However, if they're both nil, I get an error for trying to add a space between two nil values. What's a better way to handle this…
Kevin Brown
  • 12,602
  • 34
  • 95
  • 155
1
vote
2 answers

Is there a Rails FormHelper email method?

In a Rails application, I came across something like this (in a haml file): = form_for(resource, url:, ...) do |f| = f.email :email, required: true, id: 'registration_email" ... Looking at the docs, I can find an email_field method, but not…
Morgan Laco
  • 160
  • 2
  • 10
1
vote
4 answers

detecting the current_page? in navigation partial dont work

This is the code of 'shared/subnav' partial. When i click on a link it shows error No route matches {:action=>"show", :controller=>"location"} but routes are defined. i think there is some problem in below code. -if current_page? location_path =…
Murtza
  • 1,386
  • 1
  • 19
  • 27
1
vote
2 answers

Ruby Guard Watch is behaving really slow

Im using latest version of Guard and Guard-Haml. I have 7 maps in my root dir where i store Haml files in two different directories. One is in /templates/haml and one is in /haml. The total sum of the haml files is less than 10. In the other 5 maps…
Philip
  • 6,827
  • 13
  • 75
  • 104
1
vote
1 answer

Break out of the flow of divs in HAML

I've got a rails app in which a container div sits in the application layout (around the yield tag). What I'd like to know is whether it's possible to break out of the container div within the views if I'm using HAML. In standard HTML I could just…
Sketchybear
  • 67
  • 1
  • 6
1
vote
3 answers

Can Haml omit tags where the Ruby content evaluates to nil?

If I have a line in a Rails template that evaluates to nil, is there a way to have Haml not bother to generate output for that line rather than create an empty tag? For instance given this: %h4= @my_hash[:optional] ...imagine that there's no data…
RobJ
  • 129
  • 10
1
vote
1 answer

Comparing two dates in ruby on rails giving error - "can't convert Date into String"

I'm getting the error while comparing two dates in ruby on rails, I'm using PostgreSQL as my database. exp_date = ps.expiry_date if Date.today < Date.parse(exp_date) Good else Expired exp_date variable contains 2014-07-31 value from…
user3252359