views:

171

answers:

5

Is it possible to use Haml instead of a templating engine with the Catalyst web framework?

+1  A: 

As far as I know (as the author of Haml), there's no Perl implementation yet.

nex3
Text::HAML suggests otherwise, but while HAML seems, on the surface, to be language agnostic, complex templating needs would probably have to be handed off to the parent language (Ruby, Perl, whatever).
MkV
@MkV well you're in luck you can now use Template::Plugin::Haml which allows you to hand off all the complex needs to TT. (coming soon to a cpan mirror near you (I just uploaded it))
xenoterracide
A: 

From what I could see, HAML is a ruby-only thing. Like most Ruby "DSLs" it's really just using Ruby syntax as an API and can't really be done outside of Ruby without implementing all of it.

mpeters
Well there is a [PHP port](http://phphaml.sourceforge.net/) so I figured there might as well be a Perl one.
kemp
Haml isn't intimately tied to Ruby syntax. There are implementations in several different languages, each of which includes some of that language's syntax, but the basic Haml syntax is language-agnostic.
nex3
A: 

Maybe Template::Declare could be an alternative?

asjo
+2  A: 

A Perl version of Haml is in the works here:

http://github.com/vti/text-haml

Norman Clarke
+2  A: 

Text::Haml exists now. I'm looking at maybe using it instead of HTML.HAML seems to lack some complex templating constructs such as conditionals and loops, so I'm considering writing a Template::Plugin::HAML to integrate for those extra constructs.

UPDATE

I implemented Template::Plugin::Haml using Text::Haml so now you and use Haml in your Template-Toolkit templates, which of course are easy to make on Catalyst. (note: if it says it's not there give it 24 hours and check again I just uploaded it)

xenoterracide
I consider the absence of looping constructs a plus. Mainly, because that way leads to hell paved with good intentions. Sure, perhaps mangling html in perl and feeding it through as a variable is worse, but at least you're not fooling yourself about some concept of context separation that way.
Kent Fredric
@Kent well to each there own, I would think it would be harder to render stuff from databases without it. I suppose someone can also write Catalyst::View::Haml and of course just because it's TT doesn't mean you have to use TT features.
xenoterracide