I think it could be handy to allow filters to accept attributes, for example:
:sass { :css_tag => true }
With this in place, the current behavior could become a default, but those who want a CSS tag can get one. Eventually we can do a deprecation process to gracefully change the default behavior.
This would be useful for quite a few filters actually.
Regards,
Norman
On Sep 12, 2009 11:39 AM, "Chris Eppstein" <ch...@eppsteins.net> wrote:
Not every change has to be backwards compatible. I can grep for :sass in my haml files and adjust it accordingly in about 10 min. So you just make a note in the release notes about the behavior change.
On Fri, Sep 11, 2009 at 11:57 PM, Nathan Weizenbaum <nex...@gmail.com> wrote: > > I'm not sure wha...
> I am definitely not willing to change the behavior without adding a
> deprecation step first. Maintaining compatibility at least between adjacent
> releases is very important. Our users expect not to be broken without
> adequate warning.
I agree 100%. I've already lost track of sites I've created that would
break with a simple "gem update haml".
> For parameterized filters: I'd like to see more cases where this would be
> useful. If it's just for making this compatible, we might just as easily
> implement a :sass-with-tag filter or some such.
Well, I was really brainstorming, not totally arguing for the idea.
But here are some ideas that come to mind:
:css {:media => "screen"}, :css(media = "print")
:sass { :style => "compact" }
:escaped { "ó" => "ó" }
:markdown { :use => "BlueCloth" }
You could possibly even deprecate :escaped and :maruku in favor of:
:plain { :escaped => true }
:markdown { :use => "maruku" }
Another example; imagine a custom filter that takes text and pipes it
through a formatting utility like Unix's "fmt" or "par" to wrap and
justify plain text into paragraphs. Yeah, it would be slow and dumb,
but just consider it for the sake of argument. Here would be some
useful options:
:paragraph { :use => "par", :width => 72, :justify => true }
> For in-file configuration: I've considered this in the past, and come up
> against one major problem. In mos uses of (at least Ruby) Haml, the files
> aren't just handled individually. Each file can also include partials, which
> are themselves individual Haml templates. To make things more complicated,
> there are also layout files that wrap the individual templates. If we
> allowed per-template options, we would need some sensible way for them to be
> communicated from layouts to templates, and from templates to partials.
> Since we have no knowledge of how a given framework handles templates and
> partials, and indeed many of them compile templates before layouts, this
> just isn't really possible.
I see where you're coming from. Too bad, it would be a nice feature.
But yeah, way more trouble than it's worth.