You shouldn't even need to pass in options; merely including Haml::Filters::Base is enough to tell Haml to use it as a filter. However, it infers the filter name from the class name, so you're defining a filter called ":kramdownfilter". If you name the class "Kramdown" instead, it'll work.
Also, it's not recommended that you put filters in the Haml::Filters namespace. This is reserved for use by Haml. I'd put it in MyApp::Filters or something like that instead. On Fri, Aug 6, 2010 at 3:36 AM, Sid Wood <[email protected]> wrote: > Ok, so I've created the following filter; > > === lib/kramdown_filter.rb > > module Haml::Filters::KramdownFilter > include Haml::Filters::Base > > def render(text) > ::Kramdown::Document.new(text).to_html > end > end > > == > > and I've put the following in environment.rb > > == > require 'kramdown_filter' > > # define haml filter for kramdown > Haml::Template.options = { > :filters => { > 'kramdown' => Haml::Filters::KramdownFilter > } > } > == > > But I get a "ActionView::TemplateError (Filter "kramdown" is not defined.)" > error. > > Do you HAML gurus know what I'm doing wrong? > > Many thanks, > > Sid > > > > On 6 August 2010 11:01, Sid Wood <[email protected]> wrote: > >> Has anyone made a filter for kramdown? >> >> Cheers, >> >> Sid >> > > -- > 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] <haml%[email protected]>. > For more options, visit this group at > http://groups.google.com/group/haml?hl=en. > -- 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.
