Default escaping in Freemarker

后端 未结 5 1463
面向向阳花
面向向阳花 2021-01-02 05:07

In Freemarker templates we can use the escape directive to automatically apply an escaping to all interpolations inside the included block:

<#escape x as          


        
5条回答
  •  伪装坚强ぢ
    2021-01-02 05:45

    There is a solution, although it's not entirely trivial. You can create a special TemplateLoader that wraps other template loaders, and injects <#escape x as x?html> in the prolog of the template source text, and adds as the epilogue of it.

    Obvious drawbacks: - column numbers in first line will be thrown off - if your template starts with <#ftl> declaration, you need to insert <#escape> after it.

提交回复
热议问题