I have one question about yesod: how easy is it to switch templating languages? I had a look at it more than once, but hamlet always turned me off. Is it easy to switch to, say, hastache?
I don't think anyone's actually done it, because most of our users really like Hamlet. That said, switching should be a piece of cake. All you need to do is get the textual result from the templating language you're using and apply preEscapedText to it. Since we use blaze-html under the surface, any templating languages using that library's types will automatically work with Yesod.
Of course, support for type-safe URLs will vary by templating languages, so you may have to manually render URLs yourself, but that's doable via getUrlRender.
hamlet is by far Yesod's best feature. I have already ported it to Ruby (hamlet.rb) and Javascript (hamlet.js).
Many users come with different pre-conceptions about what a good template language should be, but once they actually start using Hamlet, they love it. So honestly I am not 100% sure how much effort using a different template language is because not a single user has wanted to switch to an alternative.
That said, give us your use case on the mail list (after giving hamlet a shot) and we will figure out how to make it easy for you. Also, we have users using mustache client side after first generating their mustache templates with hamlet.
My problem with Hamlet is that using it would cause a lot of unneeded pains and errors. I have a team of consultants doing all HTML coding, and they've been doing HTML for years (and are thus accustomed to writing pure HTML). If they just happen to close a single tag anywhere in any page, the application crashes.
If that is robust, then I'm not sure what definition you are using.
I agree. Having also used erb and haml, I find that Hamlet is the best of both worlds. close enough to HTML for designers to understand implicitly but with a lot of the HTML warts gone.
>but once they actually start using Hamlet, they love it ... not a single user has wanted to switch to an alternative.
Hamlet is one of the major reasons we're using snap instead of yesod. Of the 5 devs here who worked on a test app in yesod, the most favourable reaction to hamlet was "well, I guess I could live with it if I had to". Just because we didn't come ask "how hard is it to use a decent template system with yesod" doesn't mean we love hamlet. We just tried out snap and happstack instead, where using whatever template engine you want is obvious and trivial.
I think you may be re-enforcing what I said. You came with a different pre-conception about what templates should be and didn't use Hamlet for a long period of time.
On the other hand, it seems you are very adamant that you must type your own closing tags rather than have the template language ensure they are correct through indentation.
Our goal is not to make every single developer happy. If you don't appreciate DRY & reduced errors (improper closing tags in this case), Yesod is certainly not for you, no matter what template language you used.
I am not re-enforcing your statement at all. I think it is absurd to suggest that people will just suddenly start liking hamlet if they put up with it long enough. I used PHP for over a decade, I still think it is an awful template engine. Hamlet has the same problems as PHP, and added a new one. And the main part of your post I was objecting to was "everyone loves it and nobody has ever wanted to use anything else". We wanted to use something else, but once we stop using hamlet, there's nothing left making yesod unique vs happstack and snap, so we just switched instead of complaining.
Its not absurd, that has been our experience the majority of the time.
Your comment about Yesod having nothing unique shows you never really used Yesod or are very intentionally trolling. For example, Snap does not have type-safe urls and Happstack has a very different approach to its related routing. I could come up with a lot of other examples.
>Its not absurd, that has been our experience the majority of the time.
It is absurd, and saying "I only look at people who like hamlet, and all I see is people who like hamlet" doesn't make it any less absurd.
>Your comment about Yesod having nothing unique shows you never really used Yesod or are very intentionally trolling
Again, stop with the accusations and consider the very real possibility that not everyone shares your preferences.
>For example, Snap does not have type-safe urls and Happstack has a very different approach to its related routing
Except that I can use web-routes with either, and end up with the same thing. How exactly does "yesod does a trivial thing like routing slightly differently from the default way snap/happstack do it" become some compelling unique feature? How easy is it to not use yesod's routes?
I would actually appreciate if you could list some other examples. We use postgresql, so nothing persistent related was of interest to us. If we don't like the templates, that leaves form handling and some trivial stuff like sessions, routing, etc. Sessions are effectively the same across all three, routing is more flexible in snap/happstack than yesod, and yesod's form handling appears to be "like digestive-functors but dependant on persistent". If you think yesod is a good choice for someone who won't be using persistent or hamlet, then I am genuinely interested in hearing the reasoning.
You say you can use type-safe urls, but you aren't actually doing it. And the reason why is it isn't supported end-to-end by your framework. You can't stick one in a Heist template, and your routing code would become more tedious because routing is not completely trivial.
But Again, this is just one example.
In your case I doubt any benefits you would receive from switching to Yesod would overcome your switching costs. I would love to have a reasonable discussion about it. But you chose to give us zero feedback until we make a 1.0 release announcement (which means we are going to now limit our changes) and then come out of the wood-work and pic at every nit you can find in the comments of the release announcement and state some other framework is better. Stopping by #yesod to discuss, criticizing on the mail list, or helping your own favorite framework reach 1.0 would be a lot more productive.
Edit (because I can't reply): Thanks for bringing up issues on IRC. If you ask on the mail list you are guaranteed a thoughtful answer. We push users towards Hamlet in part because of the type-safe url support, but you are definitely welcome to use any template language you want.
>You say you can use type-safe urls, but you aren't actually doing it
I'm not because I don't want them. If I did I would be using blaze-html and web-routes.
>But Again, this is just one example.
I politely and genuinely asked that you provide those other examples, as the one you did provide is obviously bogus.
>But you chose to give us zero feedback until we make a 1.0 release announcement
Actually, I did ask in IRC about a year ago. And two days after I asked you offered up the same response you have been giving here: "hamlet is perfect and you are wrong for not liking it". I also got similarly slow and unhelpful responses with other issues, like how yesod used to only work on ipv6.
>and then come out of the wood-work and pic at every nit you can find in the comments of the release announcement and state some other framework is better
If you were a little less defensive and a little more reasonable, you might see that I never said anything of the sort.
First of all, working on a framework (Padrino) myself: I firmly believe that "there's nothing better then ours" without actually answering the question properly is a rude thing to tell someone who asks for replacing a part. So, is there a system in place that allows me to use any templating language that conforms to a given protocol? And where can I find that protocol? (in Padrino, for example, this is Tilt)
Okay, whats wrong with hamlet. It begins on google: "yesod hamlet" does not yield any meaningful documentation. "Shakespearean Templates" does. So "Shakespearean Templates"[1] is a whole family of languages that solves a lot of problems already solved, but type-safe. Well... okay, so I do not only have to learn a whole new framework, I also have to learn 3 new languages (-2, if I only care about HTML templating). So, to me, the whole approach rings a bit of "the world is wrong and we fix everything". Considering gregwebs answer: even more so.
Hamlet just doesn't suit my tastes. I don't like auto-closing tags on intendation - any decent text editor should assist you enough to do that properly. I like how you put thought into generating URLs, but thats nothing the templating language should take care of. Also, Hamlet assumes that you are templating HTML - I often template other types as well, for example plain text - hence a need for replacing it by something that fits all needs better. In the end, I also prefer strictly logic-less templates, so hamlet doesn't cut it.
Also, the documentation should see some love. There is no way to have a look at the features (and languages) in isolation: Its a stream of consciousness that introduces features in a half-sentence (I had to grep it to find what "^" means - it was what I expected it to be, but nevertheless).
That said, I still find Yesod a compelling framework and it will be the first haskell framework I'll try out next time I have some spare time. But the first thing I'll do is replace the templating.
[1]: I would prefer if they had anything to do with shakespeare, the esoteric programming language. ;)
> I firmly believe that "there's nothing better then ours" without actually answering the question properly is a rude thing to tell someone who asks for replacing a part
Sorry for being unclear, I asked because I am genuinely curious and I think all the yesod people love hearing feedback. If you check the yesodweb google group, you'll see that Greg and Michael are constantly begging for and responding to constructive feedback.
> Okay, whats wrong with hamlet. It begins on google: "yesod hamlet" does not yield any meaningful documentation.
Yes, documentation sucks, they're working on it.
> I like how you put thought into generating URLs, but thats nothing the templating language should take care of.
All the template does is provide some syntactic sugar with the @{...} notation. The actual URL generation is handled by the dispatch module entirely.
As for templating, shakespeare-text will do plain text, compile time templates. In general, as Greg has said, you can use anything you want.
> Sorry for being unclear, I asked because I am genuinely curious and I think all the yesod people love hearing feedback. If you check the yesodweb google group, you'll see that Greg and Michael are constantly begging for and responding to constructive feedback.
Sorry for being unclear as well: I meant the initial reply by gregwebs but didn't want to start a second comment.
Personally, I can't stand the "lets mix code and markup" style of template systems in general, which includes most templates. I also hated the indentation system, it just doesn't work well in markup heavy templating. I'm fine with indentation in programming (obviously given that we're talking about haskell), but it drove me nuts in templates as I had to indent far too much, it isn't simple blocks of code being indented, it is "indent everything that is inside something else", which is of course everything.
I found it was just as ugly and awkward as JSP/ASP/PHP, but with the added detriment of forcing me to use indentation where I didn't want it to make it look even less clear, and no closing tags so existing tools look at it and puke. I actually like syntax highlighting. I am atypical I think in that I like zope/lift/heist templates where the template is just pure HTML, and it calls out to "snippets" of code to do anything dynamic. But given the indentation issue, I'd sooner use JSP than hamlet.
As explained before in this thread "shakespear-text" is the plain-ERB of Yesod.
To unmix code and markup i'd advise simply use you discipline; it's far to handy to use it sparingly but avoid it otherwise. (But that's my opinion)
I think your contribution of a tag-based template language (like Snap's Heist, or JSP) integration with Yesod will be well received by the Yesod community.
This isn't reddit, please spare us the memes and +1s. I think the odds of such a contribution being well received are quite low given the hostility to that notion the developers of yesod still display. Given that I can't see any benefit to using yesod, it seems like a waste of time for me to contribute an unwanted template engine to it.
> This isn't reddit, please spare us the memes and +1s.
Ok. Yr right, point taken.
> I think the odds of such a contribution being well received are quite low given the hostility to that notion the developers of yesod still display.
Hostility I've never encountered. I think the Yesod is super welcoming contribs (the recent discussion on pipes/conduits being a great example of that).
> Given that I can't see any benefit to using yesod, it seems like a waste of time for me to contribute an unwanted template engine to it.
Do you mean "can't see any benefit to using yesod" over using Snap? Because I see quite a bunch of benefits in that comparison. Let me name the ones I perceive as benefits:
* More type-safe
* Write less code to get it done (using template haskell and quasiquoting -- in other general terms they are "small DSLs")
* More vibrant community
* Faster (Warp is screaming fast)
* More like Rails (yups this is an advantage to me as I quite liked Rails for some reasons that Yesod seems to copy)
The hostility is on display right here, just asking how hard it is to use another template engine gets you a "hamlet is the best" response from one of the devs.
Your list of benefits is a list of things you like. Telling me what you like doesn't make it so that I also like what you like. Yesod offers no advantages to me, as I would be using it without hamlet and without persistent, making it just an uglier happstack or snap. As I said elsewhere, I am one of the significant number of people who feel yesod's over-use of template haskell and qq is unnecessary and detrimental. It seems to appeal primarily to non-haskellers.
7+ hours before you posted this an anwser to Agorak's question "how easy is it to switch templating languages?" was kindly given by Michael Snoyman (lead dev of Yesod).
He says: "I don't think anyone's actually done it, because most of our users really like Hamlet. That said, switching should be a piece of cake. All you need to do is [...removed techincal details...]"
I cannot find anything that you describe as hostile.
I think this whole "hostility" thing you seem to perceive is simply not there. Just friendly open source collaboration for the greater good is what I see.
Yes, he posted that after Greg posted "no, hamlet is the best thing ever nobody can want to use anything else". Greg is the other yesod developer/maintainer. Notice other people have replied with similar sentiments. I think your love of yesod is blinding you.