[Rails] About Slim notation

What is Slim?

Ruby template engine. The feature is that it does not require a closing tag like html.

In addition, end such as conditional branching is not required and all are judged by indentation. Therefore, if the indentation shifts even a little, an error will occur. be careful.

Slim overview

--<> Not required

As above. It's really easy.

How to write

class

hoge.html



<div class="hoge huga">Hello!</div>

hoge.slim



.hoge.huga Hello!

if statement

hoge.html



<% if user_signed_in? %>
 <li>New post</li>
<% else %>
 <li>Login</li>
<% end %>

hoge.slim



- if user_signed_in?
li new post
- else
li login

 /end not required

that's all. It became a simple article, but please refer to it ^ ^

Recommended Posts

[Rails] About Slim notation
About Rails routing
[Rails] About ActiveJob ,!
About Rails controller
About Markdown notation
About RSpec (Rails)
[Rails 6] About main gems
[Rails] About active hash
About rails application server
About rails kaminari pagination
About rails version specification
MEMO about Rails 6 series
[rails] About devise defaults
Rails: About partial templates
About rails strong parameters
[Beginner] About Rails Session
about the where method (rails)
[Ruby on Rails] about has_secure_password
About naming Rails model methods
[Rails] About scss folder structure
[Rails] About Rspec response test
About Rails scraping method Mechanize
[Rails] About the Punk List function
About the symbol <%%> in Rails erb
[Rails] About implementation of like function
[Rails] About helper method form_with [Basic]
About =
Consideration about Rails and Clean Architecture
[Ruby on Rails] About bundler (for beginners)
[Rails 6.0] About batch saving of multiple records
[Ruby on Rails] About Active Record callbacks
[Ruby on Rails] Japanese notation of errors
[Rails] About local: true described in form_with
Rails: A little summary about data types