OSDN Git Service

Regular updates
[twpd/master.git] / haml.md
1 ---
2 title: Haml
3 category: Markup
4 layout: 2017/sheet
5 prism_languages: [haml]
6 ---
7
8 ### Doctype
9
10 ```haml
11 !!! 5
12 ```
13
14 ### Tags
15
16 ```haml
17 %html
18   %head
19     %title
20   %body
21     %h1 Hello World
22     %br/
23 ```
24
25 ### Classes and ID's
26
27 ```haml
28 %p.class-example
29 .no-tag-defaults-to-div
30 %div#butItCanBeIncluded
31 ```
32
33 ### Inline Attributes
34
35 Either hash syntax works
36
37 ```haml
38 %meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
39 %input{ :type => "text", :required => true }
40 ```
41
42 ### Ruby
43
44 ```haml
45 -# This is a comment
46 -# Anything starting with a hyphen signals to Haml that Ruby is coming
47 - @arr = [1, 2, 3]
48 - @str = "test"
49 -# Equal signals output
50 = render partial: "shared/header"
51 = yield
52 = link_to page_url
53 ```