Whenever I try to render Liquid, I get is_haml?
errors on objects/models. Is there some sort of compatibility setting to allow Liquid and HAML to run side by side?
Thanks!
Haml defines an Object#is_haml?
method to determine whether the current template context is Haml. I suppose it's possible that Liquid's context objects are undefining this somewhere... can you give me a tarball of a minimal Rails app that demonstrates the issue?
@dewski - I have run into some issues with this when attempting to leverage ActionView Helpers within custom Liquid Filters.
Example:
module LiquidFilters
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
def mailto(address, name = nil)
mail_to(address, name, :encode => "javascript")
end
end
Liquid::Template.register_filter(LiquidFilters)
I was then receiving the following error...
Liquid error: undefined method `is_haml?' for #
A simple fix was to also include Haml::Helpers in the module...
include Haml::Helpers
Not sure if this applies at all to your situation.
Best Regards,
David Baldwin
I think this will do exactly what I need, I will test this and get back to you. Thanks!
Thanks David, that fixed the issue. I am leaving this open to see how Nathan wants to handle this. Should Haml check to see if Liquid is defined, if so, include it?
Specific handling for Liquid isn't the right way to go here. We still need to figure out the underlying issue and fix that. I'd still like a Rails app repro if possible.
Here is a barebones app that should produce the issue for you...
git clone git://github.com/baldwindavid/liquidhaml.git
cd liquidhaml
rake db:setup
script/server
The "Show" view of the only post should display the error. Then take a look at...
config/initializers/liquid.rb
Uncommenting include Haml::Helpers
should make the filter work as expected.
This example uses Rails 2.3.5 and the following gems...
config.gem "haml", :version => "3.0.4"
config.gem "liquid", :version => "2.0.0"
Let me know if you need additional. Thanks.
Best Regards,
David Baldwin
Closing this issue as stale. If anybody is still affected by it let me know and I'll reopen.
Thank you @baldwindavid . adding include Haml::Helpers resolves the problem.
Most helpful comment
@dewski - I have run into some issues with this when attempting to leverage ActionView Helpers within custom Liquid Filters.
Example:
I was then receiving the following error...
A simple fix was to also include Haml::Helpers in the module...
Not sure if this applies at all to your situation.
Best Regards,
David Baldwin