9

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
jeffdill2
  • 3,968
  • 2
  • 30
  • 47
SreRoR
  • 1,151
  • 1
  • 17
  • 44
  • Possible duplicate of [Ruby concatenate strings and add spaces](http://stackoverflow.com/questions/2434885/ruby-concatenate-strings-and-add-spaces) – Szabolcs Páll Nov 23 '15 at 08:04

4 Answers4

16

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
Zzz
  • 1,703
  • 1
  • 14
  • 21
14

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
Bryan Oemar
  • 916
  • 7
  • 16
2

Another option:

p
strong Total:
span
  = [@order.currency, humanized_money_with_symbol @order.total_paisas/100].join(' ')
jeffdill2
  • 3,968
  • 2
  • 30
  • 47
1

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

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

Nick Roz
  • 3,918
  • 2
  • 36
  • 57