I am trying to use HAML (mainly for the rendering of partials) in a regular HTML/JS environment.
I'm using guard
to watch the project, mainly for .scss
files and also using Compass.
The project layout is:
-public/
--assets/
---css/
---fonts/
---img/
---js/
---sass/
--partials/
-src
--partials/
--- header.html.haml
--- footer.html.haml
--index.html/haml
Gemfile
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'
Guardfile
# 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
THE ERROR
The sass renders fine, as does the minifying, livereload, etc. And the haml compiles fine when I dont try to use = render :partial => "header"
The console output is:
$ 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>
ADDITIONAL NOTES
A similar issue is posted here: Using layouts in HAML files independently of Rails.
I cannot however relate it well enough to my environment to solve the problem.
Any help is appreciated!