因为我对HTML标签感到恼火,所以我开始将我的项目转换为HAML,因为它的结构更好.我很高兴安装提供了html2haml帮助我的工具.
虽然在语法上是正确的,处理文件给我一个奇怪的错误,我不太明白:
/stories/_story.html.haml:28: syntax error, unexpected keyword_ensure, expecting keyword_end
...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer....
... ^
/stories/_story.html.haml:31: syntax error, unexpected $end, expecting keyword_end
Run Code Online (Sandbox Code Playgroud)
我的haml源只有27行,因为我对此很新,我不知道它出错了...这里是代码:
%h1= story.title
%center
%i
by #{link_to story.user.name, story.user}
#story-short= story.short_desc
- if logged_in? and @current_user.id == story.user_id
.list-buttons
%center
= link_to 'Edit', edit_story_path(story)
|
\#{link_to 'Delete', story, :method => 'delete', :confirm => 'Are you really sure?'}
#story-body
- story.body.split("\n").each do |line|
- if line.strip.empty?
%hr/
- else
%p= line.strip
#comments
%p{:onclick => "$('#comments').find('dl').slideToggle();"} Comments to this …Run Code Online (Sandbox Code Playgroud) 好吧,简单的问题:我有一个扩展的单例对象,scala.swing.Panel我希望它能通过简单的鼠标点击做出反应.但是......好吧,它不起作用.由于Scala是一种新语言,因此找到特定问题的信息并不容易.也许你可以帮忙:
import scala.swing._
import scala.swing.event._
import java.awt.{Graphics2D, Color}
object GamePanel extends Panel {
val map: TileMap = new TileMap(10, 10)({
(x, y) =>
if (x == y) new Wood
else if (x == 5) new Water
else new Grass
})
reactions += {
case MouseClicked(src, pt, mod, clicks, pops) => {
selectedTile = (pt.x / map.tw, pt.y / map.th)
println("Clicked")
repaint
}
}
var selectedTile = (0, 0)
override def paint(g: Graphics2D) = {
map.draw(g)
g.setColor(Color.red)
g.drawRect(selectedTile._1 - …Run Code Online (Sandbox Code Playgroud)