See the documentation for filters: http://haml-lang.com/docs/yardoc/HAML_REFERENCE.md.html#filters. All text within a filter is handled by the filter, not by Haml. If you want to render a partial within a :javascript, you'll need to use #{}. It's probably a better idea to just include the javascript from a script tag, though.
On Tue, Sep 22, 2009 at 5:01 PM, Andy Koch <[email protected]> wrote: > > Hi all, > > wanting to use haml for generic templating purpose, but I don't get > how it's working... > > here's my code... > > class Hamler > def render(partial) > template = File.read("#{Rails.root}/lib/templates/# > {partial}.haml") > haml_engine = Haml::Engine.new(template) > haml_engine.render(Object.new) > end > end > > base.haml > --------------- > :javascript > = render 'button' > = render 'button' > > button.haml > ----------------- > = "alert('Button');" > > > so the problem is with when render is working as desired... > > I start a Rails console/script... > > >> template = File.read("#{Rails.root}/lib/targeting_templates/base.haml") > >> haml_engine = Haml::Engine.new(template) > >> haml_engine.render(Hamler.new) > => "<script type='text/javascript'>\n //<![CDATA[\n = render > ima.downcase\n //]]>\n</script>\nalert('Button');\n" > > What I don't get is why the method render from Hamler class works when > not indented? Inside the :javascript it just outputs text, not > calling Hamler.render > > hmmm, what am I doing wrong? > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
