如何在 ruby slim 中给出空格

how to give whitespace in ruby slim

我想用空格分隔货币和总数。

请给我一个解决方案 任何帮助将不胜感激。

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

您可以通过字符串插值来解决这个问题,方法如下:

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

或者像这样的不间断 space (nbsp):

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

另一个选项:

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

您也可以使用 Slim 输出 =>=<

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

在第一个输出上使用尾随 space

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

或在第二个输出上使用前导 space

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

verbatim text with trailing space有特殊语法, 该语法只是一个单引号:

= @user.first_name
'
= @user.last_name

| &nbsp;join(' ') 和字符串插值只是解决方法。