oxUnd / wrapper

A html/template Wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A html/template Wrapper

DESC

{{buffer "script"}}
 //balabala...
{{bufferEnd}}

it like ob_start(), ob_end() of PHP, get buffer content;

INSTALL

$ go get github.com/xiangshouding/wrapper

USE

package main

import (
    "fmt"
    "github.com/xiangshouding/wrapper"
)

func main() {
    w := wrapper.New(`{{buffer "script"}}{{.f}} {{.s}} {{.t}}{{bufferEnd}}`, func(t, c string) {
        fmt.Println(t, c)
    })

    fmt.Println(w.Execute(map[string]interface{}{
        "f": "hello",
        "s": "fis",
        "t": "wrapper",
    }))
}

API

wrapper.New

New(tmplStr string, cb func(typ, content string))

// typ "script" | "style"
// content  "script" | "css style"
func cb (typ, content) {
    //blabla...
}

About

A html/template Wrapper


Languages

Language:Go 100.0%