-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting Rails support to work #22
Comments
It looks like there is two problems. First, For now, change your gemfile to read:
And drop the following file into your module Wunderbar
module Rails
class HtmlHandler
cattr_accessor :default_format
self.default_format = :html
def self.call(template, source=nil)
%{
compiled = Proc.new {#{template.source}}
x = Wunderbar::HtmlMarkup.new(self);
instance_variables.each do |var|
x.instance_variable_set var, instance_variable_get(var)
end
x.instance_eval(&compiled)
x._.target!
}.strip # take care to preserve line numbers in original source
end
end
class JsonHandler
cattr_accessor :default_format
self.default_format = :json
def self.call(template, source=nil)
%{
compiled = Proc.new {#{template.source}}
x = Wunderbar::JsonBuilder.new(self);
instance_variables.each do |var|
x.instance_variable_set var, instance_variable_get(var)
end
x.instance_eval(&compiled)
x.target!
}.strip # take care to preserve line numbers in original source
end
end
ActionView::Template.register_template_handler :_html, HtmlHandler
ActionView::Template.register_template_handler :_json, JsonHandler
end
end With that, you should be able to serve files with an
create a file named _h1 "wunderbar"
_p 'it worked' |
That did the trick, thanks |
Can I render a haml partial from my _html template? render 'partial_name' isn't working |
I see I can't really reuse the normal render or helpers, they must output elsewhere and not to a string |
I'm pretty sure that one can have haml partials, so it must be possible. I'll try to investigate in a bit. |
An example of rendering a partial from with a wunderbar view. For illustrative purposes, 'bin/rails generate scaffold book title author'. Now you will have a directory named
A modification to the class initializer described above will allow wunderbar partials to be included from other sources (erb, haml, wunderbar, whatever). In class HtmlHandler, modify
to read:
|
That's working for me, thanks |
I'm using 1.4.2 which still has Rails support, but I get this error when a wunderbar _html template
I did include it in the Gemfile as
Is there another step?
The text was updated successfully, but these errors were encountered: