How to convert letters on the mobile phone number keypad to numbers in the Anqi CMS template?
phone2numeric
The filter can convert letters on the mobile phone number keypad to numbers.
The conversion relationship is:
{
"a": "2", "b": "2", "c": "2", "d": "3", "e": "3", "f": "3", "g": "4", "h": "4", "i": "4", "j": "5", "k": "5",
"l": "5", "m": "6", "n": "6", "o": "6", "p": "7", "q": "7", "r": "7", "s": "7", "t": "8", "u": "8", "v": "8",
"w": "9", "x": "9", "y": "9", "z": "9"
}
How to use
phone2numeric
How to use filters:
{{ obj|phone2numeric }}
For example, it is necessary to999-PONGO2
Convert to numbers, you can write this:
{{ "999-PONGO2"|phone2numeric }}
# 显示结果
999-766462
Sample Demo
{{ "999-PONGO2"|phone2numeric }}
# 显示结果
999-766462