回答編集履歴
1
追記
test
CHANGED
@@ -43,3 +43,137 @@
|
|
43
43
|
== render 'test', hash
|
44
44
|
|
45
45
|
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
### 追記
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
rails使用しているものと思い込んでいました。
|
56
|
+
|
57
|
+
railsなしで試してみたところ、エラーにはなりませんでした。
|
58
|
+
|
59
|
+
試した内容は以下の通りです。
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
**Gemfile**
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```Gemfile
|
68
|
+
|
69
|
+
source 'https://rubygems.org'
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
gem 'slim'
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
**main.rb**
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
|
85
|
+
require 'bundler'
|
86
|
+
|
87
|
+
Bundler.require
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
require 'slim/include'
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
hash = {hoge: 1, fuga: 2}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
print Tilt.new("main.slim").render(self, hash)
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
**main.slim**
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
```slim
|
110
|
+
|
111
|
+
doctype html
|
112
|
+
|
113
|
+
html lang="ja"
|
114
|
+
|
115
|
+
body
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
include test
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
**test.slim**
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```slim
|
130
|
+
|
131
|
+
p hogeは#{hoge}です。
|
132
|
+
|
133
|
+
p fugaは#{fuga}です。
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
**実行**
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```sh
|
144
|
+
|
145
|
+
$ bundle install --path vendor/bundle
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
Fetching gem metadata from https://rubygems.org/
|
152
|
+
|
153
|
+
Fetching version metadata from https://rubygems.org/
|
154
|
+
|
155
|
+
Installing temple 0.7.7
|
156
|
+
|
157
|
+
Installing tilt 2.0.5
|
158
|
+
|
159
|
+
Using bundler 1.12.5
|
160
|
+
|
161
|
+
Installing slim 3.0.7
|
162
|
+
|
163
|
+
Bundle complete! 1 Gemfile dependency, 4 gems now installed.
|
164
|
+
|
165
|
+
Bundled gems are installed into ./vendor/bundle.
|
166
|
+
|
167
|
+
```
|
168
|
+
|
169
|
+
```sh
|
170
|
+
|
171
|
+
$ ruby main.rb
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
```html
|
176
|
+
|
177
|
+
<!DOCTYPE html><html lang="ja"><body><p>hogeは1です。</p><p>fugaは2です。</p></body></html>
|
178
|
+
|
179
|
+
```
|