bml

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 6 Imported by: 2

README

bml

bml is a xml/html variant with brackets.

I created it because I wanted to read/write html templates without use of xml syntax. (which is hard to debug in my editor.)

So it has a replacement of html/template.ParseGlob function.

tmpl := template.Must(bml.ToHTMLParseGlob("", template.FuncMap{}, "tmpl/*.bml"))
Note

Unmarshal doesn't check the original xml is well-formed. So it can decode html as well.

Syntax

These are equivalent.

bml

<a> [
	<b> []
	<c>
]

xml/html

<a>
	<b></b>
	<c>
</a>
Tags with backquotes

If you need to treat content of a tag as raw string add backquote(`) to brackets.

To avoid collision with the content, number of backquotes is your choice, but ensure those are matched at both open, close brackets.

A tag with backquotes is always a leaf tag.

bml

<script> [``
function min(a, b) {
	if (a < b) {
		return a
	}
	return b
}
``]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToHTMLParseGlob

func ToHTMLParseGlob(name string, fmap template.FuncMap, pattern string) (*template.Template, error)

Types

type Elem

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

func Unmarshal

func Unmarshal(b []byte) (*Elem, error)

func (*Elem) XMLMarshal

func (e *Elem) XMLMarshal() []byte

type Text

type Text []byte

func (Text) String

func (t Text) String() string

func (Text) XMLMarshal

func (t Text) XMLMarshal() []byte

type XMLMarshaler

type XMLMarshaler interface {
	XMLMarshal() []byte
}

Jump to

Keyboard shortcuts

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