u2

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 5 Imported by: 12

README

u2

double underscore binding

GoDoc

install

$ go get -u github.com/gearintellix/u2
import "github.com/gearintellix/u2"

usage

Binding

apply u2 with binders

Binding(q string, binders map[string]string) string

example: on playground

q := "hi __@name__, how are you today. i am __:me__, nice to meet you"

qnew := u2.Binding(q, map[string]string{
    "@name": "John",
    ":me": "George",
})
fmt.Printf("%s\n", qner)

// output
// hi John, how are you today. i am George, nice to meet you
ScanPrefix

get all u2 binding with a prefix

ScanPrefix(q string, prefixs []string) (items map[string][]string)

example: on playground

q := "hi __@name__, how are you today. i am __:me__, nice to meet you"

items := u2.ScanPrefix(q, []string{"@", ":"})
fmt.Printf("%+v\n", items)

// output
// map[::[me] @:[name]]
ScanTags

get all u2tag binding

ScanTags(q string, tag string) (nq string, tags []TagInfo, err error)

example: on playground

q := `hi <foo:bar[index]{ meta1: value; meta2: "value 2"; }>hello world!</foo:bar>`

newq, items, err := u2.ScanTags(q, "foo")
if err != nil {
    panic(err)
}

fmt.Printf("%s\n\n%+v\n", newq, items)

// output
// hi __#foo:0__
//
// [{Tag:foo Key:bar Index:index Value:hello world! Meta:map[meta1:value meta2:value 2]}]

contributing

we are open, if you become contributor!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Binding

func Binding(q string, binders map[string]string) string

Binding to apply u2 with binders

func ScanPrefix

func ScanPrefix(q string, prefixs []string) (items map[string][]string)

ScanPrefix to get all u2 binding with a prefix

Types

type TagInfo

type TagInfo struct {
	Tag      string
	Key      string
	Index    string
	Value    string
	MetaKeys []string
	Meta     map[string]string
}

TagInfo object

func ScanTags

func ScanTags(q string, tag string) (nq string, tags []TagInfo, errx serr.SErr)

ScanTags to get all u2tag binding

Jump to

Keyboard shortcuts

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