빠른 참조

Slim 템플릿 엔진 치트시트

Ruby Slim 템플릿 엔진 빠른 참조 가이드: 간결한 문법, HTML 태그 및 속성, 조건문, 반복문 및 내장 엔진을 정리합니다.

· 게시일

기본 예제

doctype html
html
  head
    title Slim Examples
    meta name="keywords" content="template language"

  body
    h1 Markup examples
    #content
      p This example shows how to use Slim.

태그와 중첩

p
  | First line
  | Second line
h1.title#header Header text
a href="https://example.com" title="Home" Home Page

속성 (Attributes)

a href=url title=@title Link
input type="checkbox" checked=true
div class=["one", "two"]
div id="entry-#{entry.id}"

Ruby 코드 평가

- if user.admin?
  p Welcome Administrator!
- else
  p Welcome Guest!
= current_user.name
== raw_html_content

반복문

ul
  - @items.each do |item|
    li = item.name

내장 엔진

javascript:
  alert('Hello from Slim!');

sass:
  body
    color: #333

참고 자료

관련 주제