【发布时间】:2018-07-21 05:11:37
【问题描述】:
我正在尝试在我的 HAML 视图文件中编写条件语句。如果引用对象具有链接,我想做的是在块引用的其余部分顶部添加一个 link_to 标记。如果它为 nil,则格式化 blockqoute,顶部不带 link_to 标记。这是我目前的代码:
.carousel-inner
- @quotes.each_with_index do |quote, index|
.item{ class: ("active" if index == 0)}
- if quote.link.present?
= link_to quote.link
%blockquote
.row
.col-sm-3.text-center
%img.img-circle{:src => quote.avatar, :style => "width: 100px;height:100px;"}
.col-sm-9
%p= quote.quote
%small= quote.author
- else
%blockquote
.row
.col-sm-3.text-center
%img.img-circle{:src => quote.avatar, :style => "width: 100px;height:100px;"}
.col-sm-9
%p= quote.quote
%small= quote.author
我得到的当前堆栈错误是:
_quotes.html.haml:26:语法错误,意外关键字_else,预期关键字_end _quotes.html.haml:39:语法错误,意外关键字_确保,预期输入结束
以前有人遇到过这样的事情吗?谢谢!
【问题讨论】:
标签: ruby-on-rails ruby haml