Explicitly mark a string as safe for (HTML) output purposes. The returned object can be used everywhere a string is appropriate. If used on a method as a decorator, mark the returned data as safe. Can be called multiple times on a single string.
(s)
| 63 | |
| 64 | @keep_lazy(SafeString) |
| 65 | def mark_safe(s): |
| 66 | """ |
| 67 | Explicitly mark a string as safe for (HTML) output purposes. The returned |
| 68 | object can be used everywhere a string is appropriate. |
| 69 | |
| 70 | If used on a method as a decorator, mark the returned data as safe. |
| 71 | |
| 72 | Can be called multiple times on a single string. |
| 73 | """ |
| 74 | if hasattr(s, "__html__"): |
| 75 | return s |
| 76 | if callable(s): |
| 77 | return _safety_decorator(mark_safe, s) |
| 78 | return SafeString(s) |