doctype html
html
head
title Slim Examples
meta[charset='utf-8']
meta(name="keywords" content="template language")
meta name="author" content=author
meta property='og:image' content=asset_url('foo.png')
meta property='og:image' content=(path_to_user user)
meta(
property='description'
content='this is the song that never ends')
meta[charset='utf-8']
meta(name="keywords" content="template language")
meta name="author" content=author
You can use parentheses, brackets, or none at all.
a class=[:menu,:highlight]
You can use Ruby expressions in attributes.
.card *{'data-url' => place_path(place)}
You can destructure Ruby hashes as attributes.
ruby:
def foobar
"hello"
end
div= foobar
markdown:
### On Markdown
I am *Markdown* _text_!
{: .classname}
Slim can handle your Markdown content for longer content blocks or code
.
Depending on your parser, like Kramdown, other features might work, like assigning attributes or classes.
javascript:
alert('Slim supports embedded javascript!')
/ Comment
/! HTML comment
== yield
= t('.hello')
- 3.times do |i|
div
div
| This is text
it is nice
div
' This appends a whitespace
div
| This hackily prepends a whitespace
div
=> 'This appends a whitespace'
div
=< 'This prepends a whitespace'
<div class='foo'>
- if articles.empty?
| Nothing here
</div>
ul
li: a(href='/') Home
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️