HTML escape
Template Toolkit May 6th, 2008
ใช้ FILTER เป็นตัวจัดการ โดย FILTER จะทำการแปลง ‘<’, ‘>’ and ‘&’ ให้แสดงผลได้อย่างถูกต้อง
โดยปกติตัว engine จะ strip tag พวกนี้ไว้ก่อนแล้ว แต่บาง case อาจจำเป็นต้องใช้
{% text | html %}
หรือ
{% text FILTER html %}
text เป็นค่าที่รับจากตัว engine
สมมุติค่าของ text เป็น
HTML text may have < and > characters embedded which you want converted to the correct HTML entities.
ผมที่ได้จะออกมาเป็น
HTML text may have < and > characters embedded which you want converted to the correct HTML entities.
Related Posts
Tags: Template, Template Toolkit
About
Leave a Comment