Look! Another guy doing the exact same filter as I did ...
Nathan, Hampton,
perhaps you should consider adding this "javascript wrapper" filter as a
default filter (like erb,plain,etc) into a future version of Haml ...
Or run a poll or something! :)
Regards,
- evgeny
On 4/8/07, Hampton <[EMAIL PROTECTED]> 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 
. 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
-~----------~----~----~----~------~----~------~--~---