Reputation: 14454
I recently made the switch to slim and things are going well so far. There was one thing I noticed after running a scaffold for one of my model's show view:
= link_to 'Edit', edit_movie_path(@movie)
'|
= link_to 'Back', movies_path
As opposed to erb there's no white space before the pipe which renders these two links like this
Edit| Back
As a beginner with slim I was wondering if there was any possibility of adding space before and after characters.
I've also notice that in this same scaffold there was no space separating colons from text. So for instance:
Title: Rush Hour
is Title:Rush Hour
To fix this I've either had to add white space right after the word title or insert a single quote directly below.
# Option 1
p
b Title: # Add space where the hashtag is currenty
= @movie.title
# Option 2
p
strong Title:
'
= @movie.title
Is there any alternative to the two? I find that for the first adding that invisible space may not be evident for other devs/someone returning to the code and the second adds an entirely new line just for one character.
Upvotes: 3
Views: 2386
Reputation: 8836
According to the documentation
You can force Slim to add a trailing whitespace after a tag by adding a >.
b> Title:
[email protected]
For your second (actually first) issue, after playing around with this website for a while I came up with this
| #{link_to 'Edit', edit_movie_path(@movie)} | #{link_to 'Back', movies_path}
the |
tell slim to verbatim interpret the following line, and the two ruby link_to statements are separated by a *space*|*space*
Also this works
=' link_to 'Edit', edit_movie_path(@movie)
'|
= link_to 'Back', movies_path
Upvotes: 6