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.

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?