slim: update
This commit is contained in:
parent
adc21db20f
commit
2a02808586
50
slim.md
50
slim.md
|
@ -1,9 +1,14 @@
|
||||||
---
|
---
|
||||||
title: Slim
|
title: Slim
|
||||||
category: Ruby libraries
|
category: Ruby libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
prism_languages: [jade]
|
||||||
|
weight: -1
|
||||||
---
|
---
|
||||||
|
|
||||||
```slim
|
### Example
|
||||||
|
|
||||||
|
```jade
|
||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
head
|
||||||
|
@ -18,16 +23,35 @@ html
|
||||||
content='this is the song that never ends')
|
content='this is the song that never ends')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Attributes
|
||||||
|
|
||||||
|
```jade
|
||||||
|
meta[charset='utf-8']
|
||||||
|
meta(name="keywords" content="template language")
|
||||||
|
meta name="author" content=author
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use parentheses, brackets, or none at all.
|
||||||
|
|
||||||
### Ruby attributes
|
### Ruby attributes
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
a class=[:menu,:highlight]
|
a class=[:menu,:highlight]
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use Ruby expressions in attributes.
|
||||||
|
|
||||||
|
### Hash attributes
|
||||||
|
|
||||||
|
```jade
|
||||||
.card *{'data-url' => place_path(place)}
|
.card *{'data-url' => place_path(place)}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Inline ruby
|
You can destructure Ruby hashes as attributes.
|
||||||
|
|
||||||
```slim
|
### Inline Ruby
|
||||||
|
|
||||||
|
```jade
|
||||||
ruby:
|
ruby:
|
||||||
def foobar
|
def foobar
|
||||||
"hello"
|
"hello"
|
||||||
|
@ -36,23 +60,23 @@ ruby:
|
||||||
div= foobar
|
div= foobar
|
||||||
```
|
```
|
||||||
|
|
||||||
### Embedded js
|
### Embedded JavaScript
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
javascript:
|
javascript:
|
||||||
alert('Slim supports embedded javascript!')
|
alert('Slim supports embedded javascript!')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Comments
|
### Comments
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
/ Comment
|
/ Comment
|
||||||
/! HTML comment
|
/! HTML comment
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ruby
|
### Ruby
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
== yield
|
== yield
|
||||||
= t('.hello')
|
= t('.hello')
|
||||||
- 3.times do |i|
|
- 3.times do |i|
|
||||||
|
@ -61,7 +85,7 @@ javascript:
|
||||||
|
|
||||||
### Verbatim text
|
### Verbatim text
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
div
|
div
|
||||||
| This is text
|
| This is text
|
||||||
it is nice
|
it is nice
|
||||||
|
@ -69,7 +93,7 @@ div
|
||||||
|
|
||||||
### Inline HTML
|
### Inline HTML
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
<div class='foo'>
|
<div class='foo'>
|
||||||
- if articles.empty?
|
- if articles.empty?
|
||||||
| Nothing here
|
| Nothing here
|
||||||
|
@ -78,9 +102,11 @@ div
|
||||||
|
|
||||||
### Inline tags
|
### Inline tags
|
||||||
|
|
||||||
```slim
|
```jade
|
||||||
ul
|
ul
|
||||||
li: a(href='/') Home
|
li: a(href='/') Home
|
||||||
```
|
```
|
||||||
|
|
||||||
<http://slim-lang.com/>
|
### References
|
||||||
|
|
||||||
|
- <http://slim-lang.com/>
|
||||||
|
|
Loading…
Reference in New Issue