Skip to content
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

render partials with haml #28

Open
peterberkenbosch opened this issue Feb 25, 2010 · 3 comments
Open

render partials with haml #28

peterberkenbosch opened this issue Feb 25, 2010 · 3 comments

Comments

@peterberkenbosch
Copy link

I would love to use partials within haml. However, when I try to render a partial, the to_html method fails. What do I need to add to the render call?

=render :partial=> "sidebar"

give's me an ArgumentError, wrong number of arguments (1 for 2)

/Library/Ruby/Gems/1.8/gems/toto-0.4.1/lib/toto.rb: in to_html

  1. def self.env= env
  2. ENV['RACK_ENV'] = env
  3. end
    29.
  4. module Template
  5. def to_html page, config, &blk
  6. path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
  7. config[:to_html].call(path, page, binding)...
  8. end
    35.
  9. def markdown text
  10. if (options = @config[:markdown])
  11. Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html
  12. else
  13. text.strip
@girasquid
Copy link

I'm also having this problem, using a stock Toto install.

After doing some more tests, I managed to get things working by running <%= rende :partial => 'sidebar', :html %> - but the problem is, my partial has to be under pages/, and it renders out the entire thing(layout and all). I'm pretty new to Ruby, so I'm not sure what I've done wrong here.

@adscott
Copy link

adscott commented Jan 20, 2012

I too had this problem.

I was able to "fix" it using this monkey patch:

module Toto
  class Site
    class Context
      def to_html_without_layout(page)
        to_html page, @config
      end
    end
  end
end

And this snip in my template:

<%= render 'sidebar', :html_without_layout %>

@afknapping
Copy link

@adscott thx a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants