我试图在一个常规的HTML/JS环境中使用HAML (主要用于呈现部分)。
我使用guard观看该项目,主要用于.scss文件,也使用Compass。
项目布局如下:
-public/
--assets/
---css/
---fonts/
---img/
---js/
---sass/
--partials/
-src
--partials/
--- header.html.haml
--- footer.html.haml
--index.html/hamlGemfile
source "https://rubygems.org"
gem 'rake'
gem 'haml'
gem 'coffee-script'
gem 'rb-fsevent'
gem 'rb-inotify'
gem 'sass'
gem 'compass'
gem 'sass-globbing'
gem 'compass-validator'
gem 'oily_png'
gem 'css_parser'
gem 'uglifier'
gem 'guard'
gem 'guard-haml'
gem 'guard-coffeescript'
gem 'guard-sass'
gem 'guard-compass'
gem 'guard-concat'
gem 'guard-process'
gem 'guard-uglify'
gem 'guard-livereload'
gem 'juicer'
gem 'therubyracer'卫兵档案
# Compile stylesheet (compass watch)
if File.exists?("./config.rb")
# Compile on start.
puts `compass compile --time --quiet`
# https://github.com/guard/guard-compass
guard :compass do
watch(%r{(.*)\.s[ac]ss$})
end
end
# Minify CSS
guard 'process', :name => 'Minify CSS', :command => 'juicer merge assets/css/style.css --force -c none' do
watch %r{assets/css/style\.css}
end
# Minify JS
guard 'process', :name => 'Minify application javascript', :command => 'juicer merge assets/js/app.js --force -s' do
watch %r{assets/js/app\.js}
end
# HAML
guard :haml, input: 'src', output: 'public', run_at_start: true do
watch %r{^src/.+(\.html\.haml)}
end
# Livereload
guard :livereload do
watch(%r{.+\.(css|js|html?)$})
end错误
当我不尝试使用= render :partial => "header"时,sass呈现得很好,缩影、肝脏等也一样。haml编译得很好
控制台输出是:
$ bundle exec guard -i
Compilation took 0.105s
10:55:18 - INFO - Guard is using TerminalTitle to send notifications.
10:55:18 - INFO - Guard::Compass is waiting to compile your stylesheets.
10:55:18 - ERROR - HAML compilation failed!
> [#F8322E875F42] Error: undefined method `render' for #<Object:0x007feb43d1d8b0>附加备注
类似的问题也在这里发布:Using layouts in HAML files independently of Rails。
然而,我不能很好地把它与我的环境联系起来来解决这个问题。
任何帮助都是非常感谢的!
发布于 2014-03-05 22:09:44
这不是警卫的问题。render方法是由Rails定义的,这就是获得错误的原因。
也就是说,您可以找到如何在https://stackoverflow.com/a/6131411/304055 (您已经链接的问题)中定义它。
https://stackoverflow.com/questions/21710864
复制相似问题