2007-03-22

haml1.5试用!

关键字: class HelloController < ApplicationController
今天在rubyinside上看到HAML1.5已经出realse版了,以前没用过haml
但是看介绍,比rhtml简洁的多,但是试用了下,是不是我插件没按对的原因,还是再工程中没有配好,actionview类一直报错,一直运行不起来,mongrel总报下面截图的错误!
是不是需要在rails的工程中引入haml的包啊,刚开始学rails,可能是自己理解不对
class HelloController < ApplicationController
  def hello
    @hello = "test haml"
  end
end

haml代码如下
  #content
  .title
     %h1= @hello



更正一下,重新写了haml的代码,我觉得rails的社区越来越充实了

class HelloController < ApplicationController
  def hello
    @title = "hello haml"
    @body = "This is Haml Body"
  end
end


haml代码如下
 %html
  %head
    %title=@title
    %body
      %h1=@body
      %p Sign my guestbook
  • 6fd7c83d-4b6a-4ba6-a9cf-096e54e2c04d-thumb
  • 描述: Mongrel
  • 大小: 133.5 KB
评论
rainchen 2007-07-28
给美工还是程序员用的?
mathsfan 2007-07-26
简单的还好,稍微复杂点的用起来还真是麻烦啊```
funjackyone 2007-06-02
darkhucx 写道
谢谢xxj看到效果了 呵呵 谢谢!!!!!!
我的还是不行啊,楼主能给出,最后是怎么样解决的吗?
darkhucx 2007-03-23
谢谢xxj看到效果了 呵呵 谢谢!!!!!!
darkhucx 2007-03-22
我是下载的gem安装包安装的 但是安装时候好像有错,用gem uninstall 卸掉重新安装还是一样
xxj 2007-03-22
haml会告诉rails,以.haml结尾的模板由他处理,不需要你导入

ActionView::Base.register_template_handler('haml',Haml::Template)


先确认一下/views/hello/hello.haml是否存在?
如果确实有,看报这个错,估计是楼主haml没有安装好.
你直接下http://rubyforge.org/frs/download.php/18228/haml-1.5.0.zip压缩包,释放到/vendor/plugins.或者通过gem install haml安装
darkhucx
  • 浏览: 12833 次
  • 性别: Icon_minigender_1
  • 来自: 宁夏银川
  • 详细资料
搜索本博客
我的相册
22a41ef8-e718-43bc-a16e-da7d6daa1200-thumb
rails工作原理
共 1 张
最近加入圈子
最新评论
评论排行榜