新手问题 关于 Slim 模板的`=`标记的疑问

hxygsh · November 01, 2015 · Last by ericguo replied at November 02, 2015 · 1721 hits

Slim 模板语言里关于输出=标记有一段说明怎么也看不明白,请指点一下???的地方,谢谢!

Output = 输出标记 = The equal sign tells Slim it's a Ruby call that produces output to add to the buffer. If your ruby code needs to use multiple lines, append a backslash \ at the end of the lines, for example: 这个=告诉Slim它是Ruby调用产生到缓存的输出。如果你的Ruby代码使用多行,在断行结尾要追加\,就像下面范例:

= javascript_include_tag \
   "jquery",
   "application"

If your line ends with comma , (e.g because of a method call) you don't need the additional backslash before the linebreak. For trailing or leading whitespace the modifiers > and < are supported. 如果行尾是号(是由于某些方法的调用)就不需要在断行处加入反斜杠\标记。?????????没翻译这句啥意思 Output with trailing white space =>. Same as the single equal sign (=), except that it adds a trailing white space. ????????没翻译这句啥意思 Output with leading white space =<. Same as the single equal sign (=), except that it adds a leading white space. ????????没翻译这句啥意思

对啊……问题出在哪里了?=后面会运行一段 Ruby 代码,其返回值在经过 html_safe 处理后放在页面上。但因为 slim 是按行解析的,所以默认 Ruby 代码会写在一行中,所以如果一行没完就需要加入\提示说下面一行仍然是 Ruby 代码。,=>一类的也很明确,就是指代后面还需有一个 Ruby Object,如果已到行末就去下一行找了……

For trailing or leading whitespace the modifiers > and < are supported.

头和尾部的空格需要调剂 通过< > 来支持,到底是什么意思,没明白呀 Output with trailing white space =>. Same as the single equal sign (=), except that it adds a trailing white space. 输出如果带着行尾空格 => 符号是同样是=,除了它还要在尾部追加空格,也没明白 Output with leading white space =<. Same as the single equal sign (=), except that it adds a leading white space

这几句没看懂啊,翻译过来什么意思啊?能举个简单例子吗?多谢啦,新手别见笑。

#2 楼 @hxygsh 就是写=> 后面会多加一个空格,看输出的页面很容易验证。

You need to Sign in before reply, if you don't have an account, please Sign up first.