Referință rapidă

Fișă de referință Slim

Ghid rapid pentru motorul de șabloane Slim în Ruby: sintaxă concisă, etichete HTML, condiționale, bucle și motoare integrate.

· Publicat

Exemplu de bază

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.

Etichete și imbricare

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

Atribute

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

Evaluarea codului Ruby

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

Bucle

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

Motoare integrate

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

sass:
  body
    color: #333

Referințe

Subiecte conexe