Help us understand the problem. What is going on with this article?

Hamlを初めて使ってみる @Rails

More than 3 years have passed since last update.

インストール

  • Gemfileに追加してbundle install
# Haml
gem 'haml-rails'

Hamlとは

  • RailsのデフォルトのテンプレートエンジンはERB
  • ERBは拡張子を.erbにするとビューにRubyのコードを埋め込める
  • ただERBはHTMLを簡潔に書く機能はなく、従来通りHTMLタグは書かなくてはならない
  • Hamlは「マークアップは美しくあるべき」を原則としてテンプレートエンジン
  • 非常に簡潔にHTMLを記述することが出来る(もちろんRubyコード埋め込み等の機能も豊富)
  • 拡張子は.html.hamlにする
  • 認識するにはrails sでサーバー再起動する
  • Haml→HTMLの変換をオンラインで試す http://html2haml.herokuapp.com/

実際の記法

Hamlの書き方 - Qiita http://qiita.com/watak676/items/525ad3d8a1297e3244e3

RailsのHTMLテンプレートエンジン Haml入門 - Rails Webook http://ruby-rails.hatenadiary.com/entry/20141001/1412097051

上記の2つのサイトを確認すれば大体抑えられるはず

いやーめちゃくちゃ便利。もうタグ書きたくなくなるな。。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away