Filter filter
Template label filter filter
-
Determine whether text and array contain specified keywords
How to determine whether a line of text string contains a certain keyword in Anqi CMS template? The contains filter can determine whether a keyword is contained in a line of strings, arrays, key-value pairs, and structures. The result will return a boolean value (bool). How to use contains How to use filter: {{obj|contain: Keyword -
Delete all leading and trailing spaces, specific characters in a string
How to delete all spaces or specific characters in the beginning and end of a string in Anqi CMS template? The trim, trimLeft, and trimRight filters can delete the beginning and end spaces of strings and specific characters respectively. The trim filter can delete the string's beginning and end spaces or specific characters; the trimLeft filter can delete the string's leading spaces or specific characters; the trimRight filter can delete the string -
Calculate the number of times a keyword appears in a line of strings and in an array
How to calculate the number of times a keyword appears in a line of string or array in Anqi CMS template? The count filter can calculate the number of times a keyword appears in a line string or array (array/slice). Usage method count How to use filter: {{obj|count: keyword}} For example, calculation Welcome to use calculation in AnQiCMS (AnQiCMS) CMS appears -
Filter: Split a line of text into an array by space
How to split a line of text into an array by space in Anqi CMS template? The fields filter can split a line of text into an array in a template by spaces. The defined array is a []string{}, which can be traversed in the subsequent output. Usage methods fields filter usage: {% set values = "Text content"|fields %} {% set v -
Get the location where a keyword appears in a line string or array
How to get the location where a keyword appears in a line of strings or arrays in Anqi CMS template? The index filter can calculate where a keyword appears in a line string or array (array/slice). If the string contains multiple keywords to be found, the index returns the first occurrence position. If not found, return -1. Note: If there is Chinese in the string, then the position is calculated -
Define an array in a template
How to define an array in the template in the Anqi CMS template? A list filter can define an array in a template. The defined array is a []string{}, which can be traversed in the subsequent output. Usage method list filter usage: {% set values = '["keyword 1","keyword 2","keyword 3"]'|list %} Use single quotes or double quotation marks for conversion -
Replace a specific keyword in a string to another keyword
How to replace a word in a string with another word in Anqi CMS template? The replace filter can replace the old word old in the string with the new word new, and return the replaced new string. If old is empty, it will match at the beginning of the string and after each UTF-8 sequence. If new is empty, remove old. Usage method replace filter usage: # -
Specify repeated multiple output strings
How to output a string repeatedly in the Anqi CMS template according to the specified number of times? The repeat filter can repeat a string by a specified number of times. How to use repeat Filter: {{obj|repeat: times}} For example, repeat the Anqi CMS 5 times, you can write this: {{"Anqi CMS"|repeat:5}} # Show results Anqi CMS Anqi CMS -
Add up of numbers or strings
Filter: Add up numeric or string -
Add a backslash before predefined characters
How to add backslashes to predefined characters in strings in Anqi CMS template? The addslashes filter can prefix the predefined characters specified. These characters are single quotes ('), double quotes ("), and backslashes (\). Usage Methods Addslashes Filters are used: {{ obj|addslashes }} For example, the predefined words in "CMS" are used in "CMS" -
Convert English string letters to uppercase or lowercase
How to convert English string letters to uppercase or lowercase in Anqi CMS template? The capfirst filter converts the first letter of the English string to capitalization. Only English letters will be converted. The lower filter converts all letters in an English string to lowercase. The upper filter can convert all letters in an English string to uppercase. title filter can transfer all words in an English string -
Center the string, left, and right in the specified length format
How to center the string, left, and right in the Anqi CMS template in the specified length format? The center filter can center the string in the specified length format. If the string length is greater than the specified length, it will be displayed according to the actual length of the string. If the string length is less than the specified length, the same number of spaces will be added to both sides of the string to achieve centering. If the number of spaces that need to be supplemented is singular, the spaces to allocate the right will be compared -
Removes specified characters from any position in the string
How to remove the specified characters in any position of the string in Anqi CMS template? The cut filter can remove specified characters from any position in the string. If you remove special characters, spaces, etc., you can use the cut filter usage method. Cut filter usage method: {{ obj|cut:"keyword" }} For example, if you remove s in test, you can write this way: {{ "test"|cu -
Display time values in the specified format
How to display time values in the Anqi CMS template in the specified format? The date filter can display time values in the specified format. But it should be noted that the input of date must be a time.Time value, otherwise it will not be processed and an error will be reported. The output format is set according to Golang's time format. You can also use time, which is the same as date and the result. It's a difference to date -
Default value settings for numbers or strings and objects
How to set the default value for numbers or strings in Anqi CMS template if there are no values in numbers or strings? The default filter can set default values for numbers or strings if there is no value in numbers or strings. The default_if_none filter can determine whether the object of the pointer type is empty. If it is empty, set the default value. Usage method default filter usage method: { -
Determine whether a number can be used as a divisor
How to determine whether a number or its calculation result can be used as a divisor in the Anqi CMS template? The divisibleby filter can determine whether a number or its calculation result can be used as a divisor. The filter will return a boolean value (bool), True means yes, and False means no. Usage method divisibleby How to use filter: {{ number| -
Escape special characters in strings and js code
How to escape special characters such as HTML code in Anqi CMS templates such as strings and js code? The escape filter can escape special characters in a string. For example, output HTML code to display instead of parsing HTML code. For example, &, ' and ". Will be converted to >, & will be converted to &, " will be converted to ", ' will be converted to '. It can also be made -
Split a line of text into an array by space
How to split a line of text into an array by space in Anqi CMS template? The fields filter can split a line of text into an array in a template by spaces. The defined array is a []string{}, which can be traversed in the subsequent output. Usage methods fields filter usage: {% set values = "Text content"|fields %} {% set v -
The first or last value of a string or array
How to get the first or last value of a string or array in Anqi CMS template? The first filter can obtain the first character of a string or the first value of an array. If the original string or array is empty, nothing will be returned. If the string is Chinese, the first Chinese character is returned. The last filter can get the last character of the string or the last value of the array. If the original string or array is empty, nothing will be returned. If the string is -
Floating point numbers retain the specified decimal point
How to keep a floating point number output in Anqi CMS template? The floatformat filter can preserve a floating point number with 2 decimal output. You can also keep other decimal points specified. For example, keep 3 decimal places, etc. At the same time, negative digits are supported. If the negative number is set, the calculation is forward from the last digit. Usage method floatformat How to use the filter: {{ obj|float -
Get the number at the specified position in the number
How to get the number in the specified position in the Anqi CMS template? The get_digit filter can obtain the number at the specified position in the number. The position starts from the countdown of the number to be obtained, and the starting position is 1. If the location to be retrieved does not exist, the entire number is returned. If the original number is a number, the obtained result is the number obtained by ASCII value -48 of the character at that position. How to use get_digit -
Convert a numeric string to a floating point number or an integer
How to convert a numeric string into a floating point number or integer in Anqi CMS template? The float filter can convert a numeric string to a floating point number. If the conversion fails, return 0.0. The integer filter can convert a numeric string into an integer. If the conversion fails, return 0. Usage method float filter usage method: {{ obj|float }} integer filter enable -
Link the array into strings according to the specified splice characters
How to link arrays into strings according to specified splicing characters in Anqi CMS template? The join filter can assemble the values of the array into a new string according to the specified splice link. If the original object is a string, a splicing character will be added directly to the characters and characters. Usage method join filter usage method: {{ obj|join:"split character" }} For example, you need to use ["splits", "the -
Get the length of string, array, key-value pairs
How to get the length of strings, arrays, and key-value pairs in Anqi CMS template? The length filter can get the length of string, array, key-value pairs. For a string, the number of utf8 actual characters is calculated, one letter is one, and one Chinese character is also one. Array and key-value pairs calculate their index number. You can also use length_is to calculate the length while comparing it with the input length value, and -
Convert multiple lines of text to html tags by newline characters
How to convert multiple lines of text into html tags in Anqi CMS template? The linebreaks filter can convert multiple lines of text into html tags by line breaks. Each line begins and ends with and wraps, and if there are empty lines in the middle, use . You can also use linebreaksbr to process it. The difference from linebreaks is that linebreaksbr just switches directly -
Convert phone number keyboard letters to numbers
How to convert letters of mobile phone number keyboard to numbers in Anqi CMS template? phone2numeric filters convert phone number keyboard letters into numbers. The conversion relationship is: { "a": "2", "b": "2", "c": "2", "d": "3", "e": "3", "f": "3", "g": "4", "h": "4", "i -
Plural form of words
How to convert a word into a plural form in Anqi CMS template based on quantity? The pluralize filter can convert a word into a plural form based on the number. Usage method pluralize How to use filter: {{ obj|pluralize:"plural additional words" }} pluralize requires specifying the current number and adding plural words. Supports 0 to 2 words, use when 2 words -
Return a random character and value in a string, array
How to return a random character and value in a string and array in an Anqi CMS template? The random filter can return a random character, value in a string, array. Usage method Random filter usage method: {{ obj|random }} For example, if you return any value in [1,2,3,4,5], you can write it like this: {{ "1,2,3,4,5"|split -
Remove html tags from html code
How to remove tags from html code in Anqi CMS template? The striptags filter can remove all html tags in the html code. The removetags filter can remove the specified tags in the html code. Usage method striptags How to use the filter: {{ obj|striptags }} removetags How to use the filter -
Parses HTML code and outputs without escape
How to not escape HTML code in Anqi CMS template, but parse output? The safe filter can cancel the default escape attributes of template output, allowing the html code to be directly output to the interface, and allowing the browser to parse HTML code. It is generally used in rich text output, such as displaying article details, etc. Note: Using safe filters, by default, your output is considered safe, it does not escape special characters, so if the -
Intercept elements in strings, arrays at specified positions
How to intercept elements in strings and arrays in the Anqi CMS template? The slice filter can intercept elements in strings and arrays at specified positions. For example, get an element 3 to 7 of length 10 elements. Usage method slice How to use the filter: {{obj|slice:"from:to"}} Note: use :isolated between from and to. For example, return [1, -
Strings are cut into arrays according to the specified delimiter
How to cut strings of a specific format into arrays in Anqi CMS templates according to the specified delimiter? The split filter can cut strings of a specific format into arrays by specified delimiters. If the delimiter does not exist in the string, an array of length 1 is returned, and the value of the array is the string itself. If the delimiter is empty, it will be split into an array by each utf8 character. You can also use make_list to quickly cut strings -
Format any value into string output
How to format any values such as numbers, strings, arrays, etc. into strings and output in the Anqi CMS template? The stringformat filter can format any value such as numbers, strings, arrays, etc. into string output in a specified format. Some formatting standards: %v output structure {10 30}%+v output structure display field name {one:10 tow:30}%#v output structure source -
Intercept the string or html code and add...
How to intercept and add strings or html code in Anqi CMS template...? The truncatechars filter can truncate strings and add..., which truncates words, specifying the length including... The truncatechars_html filter can intercept and add html code..., which truncates words and specifies the length including... trun -
Url parameter escape
How to escape url parameters in Anqi CMS template? The urlencode filter can escape URL parameters. The iriencode filter can escape the url parameters. Except for /#%[]=:;$&()+,!?*@'~, all characters will be escaped according to the URL parameter escape method. Usage Method Usage Usage Method Usage Usage: {{ o -
Find and parse the url string in the text into a clickable A tag
How to find and parse the url string in the text into a clickable A tag in the Anqi CMS template? The urlize filter can find and parse url strings in text into clickable a tags. The urlizetrunc filter can find and parse the url string in the text into clickable a tag, and can specify that the text displayed by the a tag can be intercepted and displayed according to the specified length. How to use urlize -
Calculate the number of words in a string
How to calculate the number of words in a string in Anqi CMS template? The wordcount filter calculates the number of words in a string. wordcount will distinguish words by spaces. If it does not contain spaces, it is counted as a word. Returns an integer. Usage method wordcount filter usage: {{ obj|wordcount }} Example demonstration {{ ""|wordco -
Automatic text wrapping
How to automatically wrap long texts in Anqi CMS templates according to the specified length? The wordwrap filter can wrap long texts automatically by specified lengths. wordwrap will distinguish words by spaces. If it does not contain spaces, it is counted as a word. Therefore, if it is a continuous Chinese word, it will not be wrapped. Usage method wordwrap How to use the filter: {{ obj|wordwrap:numbe -
Or with non-three states
How to judge or differ from three states in Anqi CMS template? The yesno filter can be used in three states. There are three default values for yesno, namely "yes", "no", and "maybe". You can also customize these three values as other values. When the value is false, no is returned, when the value is true, yes is returned, and when the value is nil, that is, null, return maybe. use -
dump filter: print the structure type and value of the variable
How to view the structure type of variables in Anqi CMS template? The dump filter can print out the structure, type, and value of a variable. Usage method dump filter usage method: {{ obj|dump }}For example, to view the structure of bannerItem, you can write this: {{ item|dump }}# Display result&config.BannerItem{Logo:"http://127.0.0.1