Skip to content

Instantly share code, notes, and snippets.

@keisuke0818
Created November 8, 2012 03:40
Show Gist options
  • Save keisuke0818/4036591 to your computer and use it in GitHub Desktop.
Save keisuke0818/4036591 to your computer and use it in GitHub Desktop.

#Slimとは Rail系のテンプレートエンジン(PHPでも使える) Hamlより記号などが省いておりシンプルに作れる

##インストール

gem install slim slim-rails

##Gemファイル記入

gem 'slim-rails'

##bundle installする

bundle install

##Slimの書き方

doctype html
html
  head
    title Slim Examples
    meta name="keywords" content="template language"
    meta name="author" content=author
    javascript:
      alert('Slim supports embedded javascript!')

  body
    h1 Markup examples

    #content
      p This example shows you how a basic Slim file looks like.

      == yield

      - unless items.empty?
        table
          - for item in items do
            tr
              td.name = item.name
              td.price = item.price
      - else
        p
         | No items found.  Please add some inventory.
            Thank you!

    div id="footer"
      = render 'footer'
      | Copyright © #{year} #{author}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment