Yes, you can define filters via the options hash. From the options 
section of the Haml reference:

:filters
    A hash of filters that can be applied to Haml code. The keys are the
    string names of the filters; the values are references to the
    classes of the filters. User-defined filters should always have
    lowercase keys, and should have:

        * An initialize method that accepts one parameter, the text to
          be filtered.
        * A render method that returns the result of the filtering.

So you can set Haml::Template.options[:filters]['inline_javascript'] = 
InlineJavascriptFilter or whatever.

As to the newline conversion issue, I have no idea what's up with that. 
It could have something to do with the way you added the filter... try 
adding it using options, and see if it works.

- Nathan

s.ross wrote:
> I wrote my first Haml filter but I hacked it into the code. Is there  
> an "approved" way of adding rather than hacking?
>
> Also, I want to use the filter like this:
>
> :inline_javascript
>    function onLoad()
>    {
>      doSomething();
>    }
>
> and have the results come out:
>
> <script type="text/javascript">
> //<!CDATA[
>    function onLoad()
>    {
>      doSomething();
>    }
> //]]>
> </script>
>
> All this works but I get the newline conversion to &#x000A;. How do I  
> convince Haml not to perform this conversion?
>
> Thanks,
>
> Steve
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
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