6 ms·
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 t
by Argorak 15y ago
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?
- gregwebs 15y agohamlet 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.
- maxcan 15y agoI 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.
- papsosouid 15y ago>hamlet is by far Yesod's best feature In your opinion. >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.
- maxcan 15y agoWhat were the problems you saw in Hamlet?
- papsosouid 15y agoPersonally, 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.
- cies 15y ago> Personally, I can't stand [...] I also hated [...] it drove me nuts [...] I found it was just as ugly [...] https://www.google.nl/search?&q=haters-gonna-hate&tbm=isch https://www.google.nl/search?&q=haters-gonna-hate&tb... 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. http://hackage.haskell.org/package/shakespeare-text-1.0.0.1 http://hackage.haskell.org/package/shakespeare-text-1.0.0.1 http://www.yesodweb.com/book/shakespearean-templates http://www.yesodweb.com/book/shakespearean-templates
- papsosouid 15y ago
- ique 15y agoMy 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.
- Vagif-Verdi 15y agoI'm not sure where you get that info. You certainly can close tags in hamlet. (I often do). You just do not have to.
- ique 15y agoI'm getting the info from testing. I tried using Yesod for a while but kept getting this error: "A tag name may not contain a slash. Perhaps you have a closing tag in your HTML." Which you can find in the source for the parser as well: if '/' `elem` tn then fail "A tag name may not contain a slash. Perhaps you have a closing tag in your HTML." Maybe there's a way to work around this so you can use closed tags, but it sure wasn't obvious.
- b6fan 15y agoI noticed that hamlet.rb is based on slim. Why not use slim directly?
- snoyberg 15y agoI 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.
- Argorak 15y agoCan anyone please explain me why I got downvoted for asking a question about the linked framework?
- cies 15y agoI think your question is valid and upvoted you for it.