MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / underscore_escape

Function underscore_escape

web/pgadmin/browser/utils.py:27–49  ·  view source on GitHub ↗

This function mimics the behaviour of underscore js escape function The html escaped by jinja is not compatible for underscore unescape function :param text: input html text :return: escaped text

(text)

Source from the content-addressed store, hash-verified

25
26
27def underscore_escape(text):
28 """
29 This function mimics the behaviour of underscore js escape function
30 The html escaped by jinja is not compatible for underscore unescape
31 function
32 :param text: input html text
33 :return: escaped text
34 """
35 html_map = {
36 '&': "&",
37 '<': "&lt;",
38 '>': "&gt;",
39 '"': "&quot;",
40 "'": "&#39;"
41 }
42
43 # always replace & first
44 if text:
45 for c, r in sorted(html_map.items(),
46 key=lambda x: 0 if x[0] == '&' else 1):
47 text = text.replace(c, r)
48
49 return text
50
51
52def underscore_unescape(text):

Callers 3

deleteMethod · 0.90
panelFunction · 0.90
panelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected