I will explain how to install and use the Ruby template engine slim
: relaxed:
In Rails, I write html in a file called html.erb
, but it is a little troublesome to fill in<h1> </ h1>
and<%%>
every time.
With slim
, you can write html more concisely and reduce the development effort.
gemfile
in the rails directory.gem 'slim-rails'
#Gem for using slim with rails
gem 'html2slim'
# html.erb html.Gem to convert to slim
bundle install
in the terminal to reflect the gem addition.bundle install
bundle exec erb2slim app/views app/views
bundle exec erb2slim app/views app/views -d
git commit
to record the status of the file. ** If you delete a file and have problems, you can revert to the state it was in before git commit
.git log
#Examine the hash value
git reset --hard hash value
#The hash value that came out--Enter after hard to return to the specified commit.
List the basic usage of slim.
<% if %>
-
- if
<%= puts hoge %>
=
= puts hoge
<p>hoge<p>
|
p
| hoge
<h2>hogehoge</h2>
<> is not needed
h2 hogehoge
<div id = id></div>
#
# id
<div class = hoge></div>
.
.hoge
<!-- hoge -->
/
/hoge
If you compare html and slim, you can see that it is very simple to write.
If you would like to know more detailed information, please refer to the following URL.
https://qiita.com/ngron/items/c03e68642c2ab77e7283
https://techacademy.jp/magazine/10172
Recommended Posts