dynamicExpr

package
v0.0.0-...-e50112c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

func BraceStrict

func BraceStrict() *Formatter

严格匹配大括号的格式化器,要求表达式必须用 {} 包裹,即 {$表达式}

func Default

func Default() *Formatter

默认的格式化器。

func New

func New(pattern string) (*Formatter, error)

func (*Formatter) CheckJson

func (this *Formatter) CheckJson(val bool) *Pattern

替换 expr 中的表达式

func (*Formatter) Exclude

func (this *Formatter) Exclude(path ...string) *Pattern

替换 expr 中的表达式

func (*Formatter) FindAllExprIndex

func (this *Formatter) FindAllExprIndex(s string) [][]int

获取所有变量表达式的起止位置。

func (*Formatter) Format

func (this *Formatter) Format(expr string, provider ValueProvider) (string, error)

替换 expr 中的表达式

func (*Formatter) GetPattern

func (this *Formatter) GetPattern() string

func (*Formatter) IsSimpleExpr

func (this *Formatter) IsSimpleExpr(s string) bool

判断指定的字符串是否是一个简单表达式(包含且只包含一个变量表达式) 例:

'$obj.name' 是一个简单表达式,因为整体个字符串都是变量表达式。
'abc{$obj.name}' 不是简单表达式,因为除了变量表达式之外,还包含了一个 abc 前缀。

func (*Formatter) SetPattern

func (this *Formatter) SetPattern(pattern string) error

type Options

type Options struct {
	VariablePattern string
}

type Pattern

type Pattern struct {
	// contains filtered or unexported fields
}

func (*Pattern) Format

func (this *Pattern) Format(expr string, provider ValueProvider) (string, error)

替换 expr 中的表达式

type ValueProvider

type ValueProvider interface {
	Value(path string) (val interface{}, err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL