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

Pre-fill field in Simple Form

How do I pre-fill a form field in Simple Form? I tried setting the default value, but still it wouldn't show up when the form loaded: = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| =…
user3721240
1
vote
3 answers

Twig foreach that wraps each result in groups of 4 inside a div wrapper

In Twig I require that each group of four results is wrapped inside a div. This is the final html I want, each group of 4 items must be wrapped: {% for item in items %}
{{ item }} {{ item }} {{ item }} {{ item…
Ricardo Castañeda
  • 5,746
  • 6
  • 28
  • 41
1
vote
1 answer

Is it possible to have multiple highcharts with one id?

I have the following scenario in haml: #ownershipChart{"chart-data" => [["pie1", 100], ["pie2", 150], ["pie3", 200]]} #ownershipChart{"chart-data" => [["pie4", 45], ["pie5", 50], ["pie6", 20]]} and in javascript: $(function(){ …
locoboy
  • 38,002
  • 70
  • 184
  • 260
1
vote
1 answer

rendering empty partial if its not available

I am refactoring my code. I had a lot of if-else statements at various places mostly for rendering partials. So, I used the code below. Though the code works, for some account types where partial is not available, I get an error. 'nil' is not an…
Tabraiz Ali
  • 677
  • 9
  • 36
1
vote
1 answer

javascript loop over ruby database object

I am trying to go over all builds objects in project (has_many relation) and set yy to be the last updated_at one with status 'completed' The following javascript command which reside in my haml file: var yy = #{project.builds.select{|b| b.status ==…
Muky
  • 3,584
  • 3
  • 19
  • 20
1
vote
0 answers

Padrino Admin Screen

I am working on the Padrino admin screen and would like to show a dropdown list using haml in the edit view. In the List view I would like to show the country name rather than the id number it shows is this possible? I am a very newbie to haml. I am…
1
vote
1 answer

Application.html.haml file not rendered

I am new to ROR .I am working on a project which was using erb files and I have now converted them in haml. I have installed haml gem as mentioned in other posts but no luck! and using rails 4. The problem is this application.haml file is not…
Vishal
  • 113
  • 2
  • 14
1
vote
2 answers

How to extract haml code into helper

if I want to move the following code into helper %td.center= log.streaming_verification_id %td.center= log.id and render it by calling call_the_helper How to write the method call_the_helper to meet my requirement into helper -…
user3675188
  • 7,271
  • 11
  • 40
  • 76
1
vote
1 answer

haml error messages: expecting keyword_end, etc

I have a tiny haml file that's causing all sorts of irrational error messages. The file is this: %h1 Collaborator List for Private Wiki "#{@wiki.title}" - for @wiki.relationships.each do |r| - if !r.created_creator do %h3…
Ellen W
  • 217
  • 4
  • 16
1
vote
1 answer

Does heavy use of methods within a view hinder caching?

I am experimenting with implementing BEM helpers in my Rails 4 app to help me write views more pleasantly. Let's assume we have the following Haml view: = block :user_bar, unregistered: current_user.unregistered? do |b| - if…
kettlepot
  • 10,574
  • 28
  • 71
  • 100
1
vote
1 answer

Pass HAML content to HAML partial

In Rails/HAML I have the following partial: .blur .blur.underground= text .blur.foreground = yield It draws blurred out text in the underground and (should) draw the yielded content in the foreground. Unfortunately, when I call = render…
alxppp
  • 107
  • 1
  • 10
1
vote
1 answer

Can't add ":include_blank => "Please select"" to Rails 3.2 option select language(Beginner)

Beginner question I'm trying to add {:include_blank => "Please select"} in line select. %label Please choose the language you speak .user-profile-select %select{id: "user_language_language_id"} - Language.active.each do |lang| …
muzaparofff
  • 17
  • 1
  • 6
1
vote
0 answers

Bootstrap: Separate Anchor tag from Caret in Navbar

I have the following code: %a.dropdown-toggle-nav.no-active(data-toggle='dropdown' href='') Accounts %i.icon-caret-down %ul.dropdown-menu(role='menu') ... Shown Below: What I would like to do is separate out the…
Ninja
  • 1,012
  • 3
  • 14
  • 29
1
vote
1 answer

Ruby RDF library, rdf:resource closing tag

Am I right that something wrong with RDF::Writer while working with rdf:resource type of object? require 'rdf/rdfxml' output = RDF::Writer.for(:rdfxml).buffer do |writer| subject = RDF::Node.new writer << [subject, RDF.type, RDF::FOAF.Person] …
1
vote
1 answer

Form_for each loop - position element submit outsite the loop

This is mu form: .col-lg-12.col-md-12.col-sm-12 .row.userInfo .col-lg-12 %h2.block-title-2 Uw gegevens staan ​​hieronder vermeld. .w100.clearfix .col-xs-12.col-sm-6.col-md-4 .panel.panel-default …
Remco
  • 681
  • 1
  • 6
  • 20