SkRoR
SkRoR

Reputation: 1199

how to give whitespace in ruby slim

I want to seperate currency and total with whitespace.

Please suggest me a solution Any help would be appreciated.

p
strong Total:
span
    = @order.currency
    = humanized_money_with_symbol @order.total_paisas/100

Upvotes: 9

Views: 6805

Answers (4)

Nick Roz
Nick Roz

Reputation: 4250

There is special syntax for verbatim text with trailing space, and that syntax is just a single quotation mark:

= @user.first_name
'
= @user.last_name

|  , join(' ') and string interpolation are nothing but workarounds.

Upvotes: 1

Zzz
Zzz

Reputation: 1703

You can also use Slim output => or =<

https://github.com/slim-template/slim#output-

Use trailing space on the first output

p
strong Total:
span
    => @order.currency
    = humanized_money_with_symbol @order.total_paisas/100

or use leading space on the second output

p
strong Total:
span
    = @order.currency
    =< humanized_money_with_symbol @order.total_paisas/100

Upvotes: 16

jeffdill2
jeffdill2

Reputation: 4114

Another option:

p
strong Total:
span
  = [@order.currency, humanized_money_with_symbol @order.total_paisas/100].join(' ')

Upvotes: 2

Bryan Oemar
Bryan Oemar

Reputation: 926

You can solve this with string interpolation, by doing something like this:

p
strong Total:
span
    = "#{@order.currency} #{humanized_money_with_symbol @order.total_paisas/100}"

Or with a non-breaking space (nbsp) like this:

p
strong Total:
span
    = @order.currency
    | &nbsp;
    = humanized_money_with_symbol @order.total_paisas/100

Upvotes: 14

Related Questions