Back to godoc.org
github.com/shiyanhui/hero

package hero

v0.0.2
Latest Go to latest
Published: Jun 7, 2019 | License: Apache-2.0 | Module: github.com/shiyanhui/hero

Index

Constants

const (
	TypeBytesBuffer = "bytes.Buffer"
	TypeIOWriter    = "io.Writer"
)
const (
	TypeImport = iota
	TypeDefinition
	TypeExtend
	TypeInclude
	TypeBlock
	TypeCode
	TypeEscapedValue
	TypeRawValue
	TypeNote
	TypeHTML
	TypeRoot
)
const (
	Bool      = "b"
	Int       = "i"
	Uint      = "u"
	Float     = "f"
	String    = "s"
	Bytes     = "bs"
	Interface = "v"
)
const (
	OpenBrace   = '{'
	CloseBrace  = '}'
	LT          = '<'
	GT          = '>'
	Percent     = '%'
	Exclamation = '!'
	Colon       = ':'
	Tilde       = '~'
	Plus        = '+'
	Equal       = '='
	At          = '@'
	Pound       = '#'
	Space       = ' '
	BreakLine   = '\n'
)

func CheckExtension

func CheckExtension(path string, extensions []string) bool

func EscapeHTML

func EscapeHTML(html string, buffer *bytes.Buffer)

EscapeHTML escapes the html and then put it to the buffer.

func FormatBool

func FormatBool(b bool, buffer *bytes.Buffer)

FormatBool format bool to string and then put the result to the buffer.

func FormatFloat

func FormatFloat(f float64, buffer *bytes.Buffer)

FormatFloat format float64 to string and then put the result to the buffer.

func FormatInt

func FormatInt(i int64, buffer *bytes.Buffer)

FormatInt format int to string and then put the result to the buffer.

func FormatUint

func FormatUint(u uint64, buffer *bytes.Buffer)

FormatUint formats uint to string and put it to the buffer. It's part of go source: https://github.com/golang/go/blob/master/src/strconv/itoa.go#L60

func Generate

func Generate(source, dest, pkgName string, extensions []string)

Generate generates Go code from source to test. pkgName represents the package name of the generated code.

func GetBuffer

func GetBuffer() *bytes.Buffer

GetBuffer returns a *bytes.Buffer from sync.Pool.

func PutBuffer

func PutBuffer(buffer *bytes.Buffer)

PutBuffer puts a *bytes.Buffer to the sync.Pool.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier