almost 4 years ago


Mac OS X Yosemite 10.10.1
Ruby 2.1.5
Rails 4.1.8


slim ( )
slim-rails ( )
redcarpet ( )


  • Slim allows you to write very minimal templates which are easy to maintain and pretty much guarantees that you write well-formed HTML and XML
  • We also think that the Slim syntax is also aesthetic and makes it much more fun to write templates. Since you can use Slim as a drop-in replacement in all the major framework you can start easily.
  • The Slim architecture is very flexible and allows you to write syntax extensions and plugins.

Yes, Slim is speedy! Slim was developed right from the start with performance in mind.
Benchmarks are done for every commit at
Don't trust the numbers? That's as it should be. Please try the benchmark rake task yourself!

However in our opionion you should use Slim because of its features and syntax. We just ensure that Slim doesn't have a negative impact on the performance of your application.


1. Gemfile 設定

添加必要的 gem 套件至 Gemfile 檔中

# Use slim template
gem 'slim'
gem 'slim-rails'
# slim support markdown
gem 'redcarpet'
$ bundle install

2. 使用方法則參考官網說明

3. code 不斷行,無產生空格問題

因為 slim 預設將 code 的 tag 彼此之間全部不斷行,以致相較以往 html 編寫方式,斷行可產生一個空格,導致版面有所出入,解決方式則是在 tag 後面連著加上 '`',即可產生一個空格。

a href=new_session_path(:user)
  =' fa_icon 'sign-in fw'
  = t :sign_in_with_account

4. 使用 markdown

  # title
  - list1
  - list2
← 從 rvm 轉換到 rbenv Deploy Rails 4 app to a VPS with Capistrano 3 →
comments powered by Disqus