Hi,

I try to yse the filter, but all I get is a:

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment ...
Exiting

And nothing more ...

I have rails 1.2.3 and placed inline_javascript.rb in my lib dir

If I change the name, say to InlineJavascriptF

(and change environment.rb accordingly:
Haml::Template.options[:filters]['inline_javascript'] =
InlineJavascriptF)

I get a

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment ...
Exiting
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/
dependencies.rb:266:in `load_missing_constant': uninitialized constant
InlineJavascriptF (NameError)

What am I missing?

Dirk

Btw - great stuff, Haml!

On Apr 8, 9:29 pm, "s.ross" <[EMAIL PROTECTED]> wrote:
> To wrap this up, I posted a simple how-to on my blog, combining
> Nathan, Hampton, and Evgeny's comments:
>
> http://calicowebdev.com/blog/show/11
>
> If you're ever in need of writing a Haml filter, I hope this gets you
> underway faster :)
>
> --steve
>
> On Apr 7, 2007, at 8:39 PM, Hampton wrote:
>
>
>
> > This may not even be worth mentioning, but you can do this.
>
> > Haml::Template.options[:filters] = {
> >                      :inline_javascript=> InlineJavascriptFilter,
> >                      :tip_builder         => TipFilter
> >                   }
>
> > Just to show the built-out syntax.
>
> > -hampton.
>
> > On 4/7/07, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
>
> >> 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