Haml-4.0を使うときの6つの注意点
2013-02-14

閉じタグに嫌悪感を抱く全国519万人のHamlファンの皆さんこんにちは。(ruby-toolbox調べ)
bundle update
したらHamlが4.0になったそうです。同時に、いろんな機能追加が行われたとのこと。
「一部のアプリは動かなくなるかもしれんよ」とあったので、ここに書き写しておく。
HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
your application:
* Support for Ruby 1.8.6 dropped
* Support for Rails 2 dropped
* Sass filter now always outputs <style> tags
* Data attributes are now hyphenated, not underscored
* html2haml utility moved to the html2haml gem
* Textile and Maruku filters moved to the haml-contrib gem
For more info see:
http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
Ruby 1.8.6 サポート、やめました
諦めましょう。
Rails 2.x サポート、やめました
諦めましょう。
:sass filterが<style>
タグを一緒に出力します
いままでは、こう書いたら、
%style
:sass
div
color: red
このようにレンダリングされてました。
<style>
div { color: red; }
</style>
これからは、:sass
フィルターだけで、
:sass
div
color: red
style
タグを含むカタチでレンダリングしてくれるとのこと。
<style>
div { color: red; }
</style>
Data attributes はアンスコでなくハイフンになりました
このように書くと、
.foo{data: {a: "b", c: {d: "e", f: "g"}}}
こうなります。
<div class='foo' data-a='b' data-c-d='e' data-c-f='g'></div>
すごく便利そう!