MCPcopy Create free account
hub / github.com/cel-expr/cel-go / parseAndFormatClause

Function parseAndFormatClause

ext/formatting.go:831–844  ·  view source on GitHub ↗

parseAndFormatClause parses the format clause at the start of the given string with val, and returns how many characters were consumed and the substituted string form of val, or an error if one occurred.

(formatStr string, val ref.Val, callback formatStringInterpolator, list formatListArgs, locale string, maxPrecision int)

Source from the content-addressed store, hash-verified

829// parseAndFormatClause parses the format clause at the start of the given string with val, and returns
830// how many characters were consumed and the substituted string form of val, or an error if one occurred.
831func parseAndFormatClause(formatStr string, val ref.Val, callback formatStringInterpolator, list formatListArgs, locale string, maxPrecision int) (int, string, error) {
832 i := 1
833 read, formatter, err := parseFormattingClause(formatStr[i:], callback, maxPrecision)
834 i += read
835 if err != nil {
836 return -1, "", newParseFormatError("could not parse formatting clause", err)
837 }
838
839 valStr, err := formatter(val, locale)
840 if err != nil {
841 return -1, "", newParseFormatError("error during formatting", err)
842 }
843 return i, valStr, nil
844}
845
846func parseFormattingClause(formatStr string, callback formatStringInterpolator, maxPrecision int) (int, clauseImpl, error) {
847 i := 0

Callers 1

parseFormatStringFunction · 0.85

Calls 3

parseFormattingClauseFunction · 0.85
newParseFormatErrorFunction · 0.85
formatterFuncType · 0.85

Tested by

no test coverage detected