dongzhen6554 2014-11-14 14:04
浏览 35
已采纳

Phalcon Volt引擎的自动纵行设置?

The Phalcon documentation mentions how to autoescape with a filter |e or through autoescape-mode {% autoescape true %}. But Twig has autoescaping enabled by default and lets you pass it as an option to the Twig Environment object. So in Twig you can control autoescaping globally for your app.

Does Phalcon provide the same posibility? I really couldn't find this answer on Google and my C-knowledge is non-existent.

  • 写回答

1条回答 默认 最新

  • dsoxcj7276 2014-11-20 01:24
    关注

    Yeah this might be a problem because AFAIK in Volt's implementation escaping is made to deal with blocks or expressions, so it might be hard to determine what you should scape.

    IMHO, the easier way to achieve this is by customizing the compiler to escape the expression only if the value is coming from a external source, like a variable or method return. So... the answer is basically no, Volt can't do that. But indeed this would be an excellent NRF to the framework.


    EDIT

    Thinking a bit more about the problem I've realized that I do something similar in my application. Data exchange in CRUD operations are mostly a cycle between 'forms', controllers and persistence and besides all helpers provided by Phalcon (from the ORM to the Form abstractions) we need to apply some conventions to automatize even more our CRUD operations that are basically the same most of time.

    So I have two components that helps me out in fetching model data from forms and another one to help with model data from my database. In both of these components value conversions, filters and validations are called automatically on each operation.

    I'm saying that because the default filter for strings is the string escape. What I mean is that you might have better results if worrying about data sanitization at any data input to your controllers (i.e. from forms or the database). As bonus you get more consistent and strong typed values in your models to make your business logic implementations much simpler.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?