Templating packages for Haskell

谁说胖子不能爱 提交于 2019-11-28 18:47:57

问题


What are some preferred packages for templating in Haskell. Something similar to Django Templates, or PHP.

I don't want to always use it with HTML. It can be any other thing. I guess what I want is a string interpolation library, that also supports loops, registration of filter/escape utilities, if conditions, etc.


回答1:


According to the Hackage popularity statistics, the top three packages, by far, are (2014):

  1. (29,000 downloads) shakespeare -- replacement for hamlet.
  2. (27,816 downloads) hamlet -- yesod framework templating
  3. (10,625 downloads) heist -- snap framework templating
  4. (7099 downloads) HStringTemplate -- general purpose templating

You can see more about these two systems in this question.




回答2:


Some related packages:

  • Bravo - Static text template generation library
  • chunks - Simple template library with static safety
  • halipeto - Haskell Static Web Page Generator
  • hamlet - Haml-like template files that are compile-time checked
  • hastache - Haskell implementation of Mustache templates
  • heist - An xhtml templating system
  • HStringTemplate - StringTemplate implementation in Haskell.
  • Interpolation - Multiline strings, interpolation and templating.
  • PCLT - Extension to Show: templating, catalogizing, languages, parameters, etc.
  • press - Text template library targeted at the web / HTML generation
  • template - Simple string substitution
  • twine - very simple template language



回答3:


hastache seems rather well designed imo. Bravo is a cool idea, but suited for what I want (loops, etc.), and it assumes all parameters are, in some way or another, strings.




回答4:


interpolatedstring-perl6 provides a simple and well designed Quasiquoter to produce interpolated String/Text from Templates containing arbitrary Haskell expressions.




回答5:


There is also karver (github) package, not mentioned in other answers. Author says “its syntax is heavily inspired by Jinja2”, but “it isn't as full featured or production ready as Jinja is”.



来源:https://stackoverflow.com/questions/5770168/templating-packages-for-haskell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!