Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Haml多行表示非常长的html属性_Ruby On Rails_Ruby_Haml - Fatal编程技术网

Ruby on rails Haml多行表示非常长的html属性

Ruby on rails Haml多行表示非常长的html属性,ruby-on-rails,ruby,haml,Ruby On Rails,Ruby,Haml,我的编码伙伴和我今天花了很多时间试图找出如何重构具有很长属性的链接以使其成为多行: %a.pull-right{ href: "#", "data-html" => "true", rel: "tooltip", "data-placement" => "left", title: "This is really just so much text. The real thing goes on and on and on, much longer than this. It

我的编码伙伴和我今天花了很多时间试图找出如何重构具有很长属性的链接以使其成为多行:

%a.pull-right{ href: "#", "data-html" => "true", rel: "tooltip", 
  "data-placement" => "left", title: "This is really just so much text. The real thing goes on and on and on, much longer than this. It also contains some line breaks.<br><br>We'd really like to be able to wrap it around so it's readable in the code." }

这显然更好,但我更愿意把一切都放在一个街区里。有没有一种方法可以在不将文本移动到另一个文件的情况下执行此操作?

使用
对我来说可以:

%a.pull-right{ href: "#", "data-html" => "true", rel: "tooltip",
  "data-placement" => "left", title: "This is really just so much text. |
  The real thing goes on and on and on, much longer than this. It also  |
  contains some line breaks.<br><br>We'd really like to be able to wrap |
   it around so it's readable in the code." }                           |
%a.pull-right{href:“#”,“数据html”=>“true”,rel:“工具提示”,
“数据放置”=>“左”,标题:“这真是太多的文字了|
真实的东西会持续不断,比这要长得多。它也|
包含一些换行符。
我们非常希望能够换行| 在代码中,它是可读取的|
输出:

<a class='pull-right' data-html='true' data-placement='left' href='#' rel='tooltip' title="This is really just so much text. The real thing goes on and on and on, much longer than this. It also  contains some line breaks.&lt;br&gt;&lt;br&gt;We'd really like to be able to wrap it around so it's readable in the code."></a>

请注意,即使最后一行也需要在其末尾具有管道字符


此外,您可能需要将

更改为
\n
,以使新行在浏览器中正常工作。

您也可以在code review.stackexchange.com上发布该问题。也许更多的是关于这个主题……这对于代码审查来说可能是一个好问题,只要:(a)代码是有效的,(B)它在任何方面都不是假设的或不完整的。如果您选择转到,请在发帖前阅读。如果您有任何顾虑或问题,请随时联系。您是否尝试过i18n方法,以及在中存储字符串有什么问题?Its..谢谢,这非常有效。我不知道我们昨天做错了什么,因为它的工作方式和今天完全一样。这里对我来说的关键是看到结尾的那一行也有|!
<a class='pull-right' data-html='true' data-placement='left' href='#' rel='tooltip' title="This is really just so much text. The real thing goes on and on and on, much longer than this. It also  contains some line breaks.&lt;br&gt;&lt;br&gt;We'd really like to be able to wrap it around so it's readable in the code."></a>