Hi Nathan,

Thanks for the advice but I'm not having any joy unfortunately.

I've placed the following in lib/kramdown_filter.rb

module KramdownFilter
  include Haml::Filters::Base

  def render(text)
    ::Kramdown::Document.new(text).to_html
  end
end


I require the module in the environment.rb;

require 'kramdown_filter'


Then in my haml templates I use

:kramdownfilter
   #[email protected]}

But I still get "Filter "kramdown_filter" is not defined."


Any help is greatly appreciated.


Sid





On 8 August 2010 08:12, Nathan Weizenbaum <[email protected]> wrote:

> 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] <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.

Reply via email to