Phillipp
Phillipp

Reputation: 264

Trailing whitespace after tag with class with slim

I'm trying to add trailing whitespace in a slim template after a font-awesome icon.

The template looks like this:

=link_to edit_path(the_object) do
  i.icon-pencil
  | edit

I want to add whitespace after the tag (or before the text), so I tried the following combinations:

=link_to edit_path(the_object) do
  i>.icon-pencil
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil>
  | edit


=link_to edit_path(the_object) do
  i<.icon-pencil
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil<
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil
  < edit

and many more...

Maybe I'm just too stupid to understand the docs. The only solution I found working (but it looks super unelegant) was:

=link_to edit_path(the_object) do
  i.icon-pencil
  '
  | edit

Upvotes: 4

Views: 2753

Answers (2)

shadowreplicant
shadowreplicant

Reputation: 15

I came here from google search, and slim template 4.0.1 works as expected.

There is correct answer in the question:

= link_to edit_path(the_object) do
  i.icon-pencil>
  | edit

will produce trailing space after <i> tag

<a href="http://a.lv"><i class="icon-pencil"></i> edit</a>

Upvotes: 1

asmann
asmann

Reputation: 46

Try this: |  edit (two spaces)

From the docs: "If the text starts on the same line, the left margin is set at the indent of the pipe + one space. Any additional spaces will be copied over."

Upvotes: 3

Related Questions