Perl: Alternatives to template toolkit

后端 未结 5 903
梦毁少年i
梦毁少年i 2021-01-30 18:25

I have been using template toolkit for extending an existing domain specific language(verilog) for over 3 years now. While overall I am happy with it, the major irritant is that

5条回答
  •  清歌不尽
    2021-01-30 19:28

    I can only recommend Text::Xslate here. It is better than TT in every way and beats out most of the competition as well. And lastly, it fits all your requirements. Literally. All of them.

    It is even proven in practice, as it is used by one of the Top 100 websites worldwide and one of the Top 10 websites in Japan: Livedoor

    Xslate in comparison to TT:

    • faster startup
    • faster processing
    • strict mode by default
    • much more advanced strict mode that catches inconsistencies beyond just "var is undef"
    • detailed errors that show the exact template position
    • automatic HTML entity escaping (XSS-safe)
    • actively maintained and not just left to languish
    • syntax is straight-forward and modern perl

    Two things to note for your special case:

    1. As you're porting from TT, you might want to pass syntax => 'TTerse' to the constructor to get a syntax that's designed to be as close to TT as possible.
    2. When generating non-HTML, you want to pass type => 'text' to the constructor to disable html_escape interpolation.

提交回复
热议问题