當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tplx.ExecTplHelper函數代碼示例

本文整理匯總了Golang中github.com/pbberlin/tools/net/http/tplx.ExecTplHelper函數的典型用法代碼示例。如果您正苦於以下問題:Golang ExecTplHelper函數的具體用法?Golang ExecTplHelper怎麽用?Golang ExecTplHelper使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ExecTplHelper函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: runTestX

func runTestX(
	w http.ResponseWriter,
	r *http.Request,
	f1 func() string,
	f2 func(fsi.FileSystem) (*bytes.Buffer, string),
) {

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Run a test"}))
	defer wpf(w, tplx.Foot)

	wpf(w, "<pre>\n")
	defer wpf(w, "\n</pre>")

	if f1 == nil {
		f1 = dsfs.MountPointLast
	}
	mnt := f1()
	fs := getFS(appengine.NewContext(r), mnt)

	bb := new(bytes.Buffer)
	msg := ""
	wpf(bb, "created fs %v\n\n", mnt)
	bb, msg = f2(fs)
	w.Write([]byte(msg))
	w.Write([]byte("\n\n"))
	w.Write(bb.Bytes())

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:28,代碼來源:fs_tests.go

示例2: FetchHTML

// FetchHTML executes the fetch commands.
// It creates the configured filesystem and calls the fetcher.
func FetchHTML(w http.ResponseWriter, r *http.Request, fcs []FetchCommand) {

	lg, lge := loghttp.Logger(w, r)
	var err error

	fs := GetFS(appengine.NewContext(r))
	// fs = fsi.FileSystem(memMapFileSys)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Requesting files"}))
	defer wpf(w, tplx.Foot)

	wpf(w, "<pre>")
	defer wpf(w, "</pre>")

	err = fs.WriteFile(path.Join(docRoot, "msg.html"), msg, 0644)
	lge(err)

	// err = fs.WriteFile(path.Join(docRoot, "index.html"), []byte("content of index.html"), 0644)
	// lge(err)

	err = fs.MkdirAll(path.Join(docRoot, "testDirX/testDirY"), 0755)
	lge(err)

	for _, config := range fcs {
		FetchUsingRSS(w, r, fs, config)
	}

	lg("fetching complete")

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:32,代碼來源:3_rcv_cmd.go

示例3: setFSType

func setFSType(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Set filesystem type"}))
	defer wpf(w, tplx.Foot)

	stp := r.FormValue("type")
	newTp, err := strconv.Atoi(stp)

	if err == nil && newTp >= 0 && newTp <= 2 {
		whichType = newTp
		wpf(w, "new type: %v<br><br>\n", whichType)
	}

	if whichType != 0 {
		wpf(w, "<a href='%v?type=0' >dsfs</a><br>\n", UriSetFSType)
	} else {
		wpf(w, "<b>dsfs</b><br>\n")
	}
	if whichType != 1 {
		wpf(w, "<a href='%v?type=1' >osfs</a><br>\n", UriSetFSType)
	} else {
		wpf(w, "<b>osfs</b><br>\n")
	}
	if whichType != 2 {
		wpf(w, "<a href='%v?type=2' >memfs</a><br>\n", UriSetFSType)
	} else {
		wpf(w, "<b>memfs</b><br>\n")
	}

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:30,代碼來源:fs_tests.go

示例4: HandleHomeVari

func HandleHomeVari(w http.ResponseWriter, r *http.Request, successLandingURL, signoutLandingURL string) {

	format := `
		<a href='%v?mode=select'>Signin with Redirect (Widget)</a><br><br> 

		<a href='%v'>Signin Success Landing</a><br><br> 
		<a href='%v'>Signout </a><br><br>

		<a href='%v'>Signout Landing</a><br> 
		<a href='%v'>Branding for Account Chooser</a><br> 
	`

	str := fmt.Sprintf(format,
		WidgetSigninAuthorizedRedirectURL,
		successLandingURL,
		signOutURL,

		signoutLandingURL,
		accountChooserBrandingURL,
	)

	bstpl := tplx.TemplateFromHugoPage(w, r) // the jQuery irritates
	fmt.Fprintf(w, tplx.ExecTplHelper(bstpl, map[string]interface{}{
		"HtmlTitle":       "Google Identity Toolkit Overview",
		"HtmlDescription": "", // reminder
		"HtmlContent":     template.HTML(str),
	}))

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:29,代碼來源:handlers.go

示例5: GetHomeTpl

func GetHomeTpl(w http.ResponseWriter, r *http.Request, title, body string) *template.Template {

	if body == "" {
		body = IDCardHTML + UserInfoHTML
	}

	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	bstpl := tplx.TemplateFromHugoPage(w, r)

	b := new(bytes.Buffer)

	fmt.Fprintf(b, tplx.ExecTplHelper(bstpl, map[string]interface{}{
		// "HtmlTitle":       "{{ .HtmlTitle }}", // this seems to cause problems sometimes.
		"HtmlTitle":       title,
		"HtmlDescription": "", // reminder
		"HtmlHeaders":     template.HTML(Headers),
		"HtmlContent":     template.HTML(body),
	}))

	intHomeTemplate, err := template.New("home").Parse(b.String())
	lg(err)

	return intHomeTemplate

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:26,代碼來源:tpl_creation.go

示例6: resetMountPoint

func resetMountPoint(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Mountpoint reset"}))
	defer wpf(w, tplx.Foot)

	wpf(w, "<pre>\n")
	defer wpf(w, "\n</pre>")

	wpf(w, "reset %v\n", dsfs.MountPointReset())

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:11,代碼來源:register_handlers.go

示例7: decrMountPoint

func decrMountPoint(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Mountpoint decrement"}))
	defer wpf(w, tplx.Foot)

	wpf(w, "<pre>\n")
	defer wpf(w, "\n</pre>")

	wpf(w, "counted down %v\n", dsfs.MountPointDecr())

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:11,代碼來源:register_handlers.go

示例8: deleteAll

func deleteAll(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	err := r.ParseForm()
	lg(err)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Delete all filesystem data"}))
	defer wpf(w, tplx.Foot)

	confirm := r.FormValue("confirm")
	if confirm != "yes" {
		wpf(w, "All dsfs contents are deletes. All memfs contents are deleted<br>\n")
		wpf(w, "Put a get param into the URL ?confirm - and set it to 'yes'<br>\n")
		wpf(w, "Put a get param 'mountname' into url; i.e. mountname=mntftch<br>\n")
		return
	}

	wpf(w, "<pre>\n")
	defer wpf(w, "\n</pre>")

	//
	//
	fs := dsfs.New(
		dsfs.AeContext(appengine.NewContext(r)),
	)

	mountName := r.FormValue("mountname")
	if mountName != "" {
		wpf(w, "mountame = "+mountName+"\n")
		fs = dsfs.New(
			dsfs.AeContext(appengine.NewContext(r)),
			dsfs.MountName(mountName),
		)
	}

	wpf(w, "dsfs:\n")
	msg, err := fs.DeleteAll()
	if err != nil {
		wpf(w, "err during delete %v\n", err)
	}
	wpf(w, msg)

	memMapFileSys = memfs.New()
	wpf(w, "\n")
	wpf(w, "memMapFs new")

	// cleanup must be manual
	osFileSys = osfs.New()

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:51,代碼來源:spec_ops.go

示例9: incrMountPoint

func incrMountPoint(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Mountpoint increment"}))
	defer wpf(w, "\n</pre>")

	wpf(w, "<pre>\n")
	defer wpf(w, tplx.Foot)

	xx := r.Header.Get("adapter_01")
	wpf(w, "adapter set %q\n", xx)

	wpf(w, "counted up %v\n", dsfs.MountPointIncr())

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:14,代碼來源:register_handlers.go

示例10: sendUpload

func sendUpload(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, _ := loghttp.Logger(w, r)
	// c := appengine.NewContext(r)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Post an Upload"}))
	defer wpf(w, tplx.Foot)

	tData := map[string]string{"Url": UrlUploadReceive}
	err := tplBase.ExecuteTemplate(w, "tplName01", tData)
	if err != nil {
		lg("tpl did not compile: %v", err)
	}

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:15,代碼來源:11_post_html_form.go

示例11: DeleteSubtree

func DeleteSubtree(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, lge := loghttp.Logger(w, r)

	err := r.ParseForm()
	lge(err)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Delete Subtree for curr FS"}))
	defer wpf(w, tplx.Foot)

	if r.Method == "POST" {
		wpf(w, "<pre>\n")
		defer wpf(w, "\n</pre>")

		mountPoint := dsfs.MountPointLast()
		if len(r.FormValue("mountname")) > 0 {
			mountPoint = r.FormValue("mountname")
		}
		lg("mount point is %v", mountPoint)

		pathPrefix := "impossible-value"
		if len(r.FormValue("pathprefix")) > 0 {
			pathPrefix = r.FormValue("pathprefix")
		}
		lg("pathprefix is %v", pathPrefix)

		fs := getFS(appengine.NewContext(r), mountPoint)
		lg("created fs %v-%v ", fs.Name(), fs.String())

		lg("removing %q - and its subtree  ...", pathPrefix)
		err := fs.RemoveAll(pathPrefix)
		lge(err)

		errMc := memcache.Flush(appengine.NewContext(r))
		lge(errMc)

		if err == nil && errMc == nil {
			lg("success")
		}

	} else {
		tData := map[string]string{"Url": UriDeleteSubtree}
		err := tplBase.ExecuteTemplate(w, "tplName01", tData)
		lge(err)

	}

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:48,代碼來源:spec_ops.go

示例12: handleSignOutLanding

func handleSignOutLanding(w http.ResponseWriter, r *http.Request) {

	format := `
		Signed out<br>
		<a href='%v'>Home</a><br> 
	`

	str := fmt.Sprintf(format, homeURL)

	bstpl := tplx.TemplateFromHugoPage(w, r) // the jQuery irritates
	fmt.Fprintf(w, tplx.ExecTplHelper(bstpl, map[string]interface{}{
		"HtmlTitle":       "Google Identity Toolkit Overview",
		"HtmlDescription": "", // reminder
		"HtmlContent":     template.HTML(str),
	}))

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:17,代碼來源:handlers.go

示例13: staticFetchViaPosting2Receiver

// Submit test commands by http posting them.
func staticFetchViaPosting2Receiver(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, lge := loghttp.Logger(w, r)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "JSON Post"}))
	defer wpf(w, tplx.Foot)

	wpf(w, "<pre>")
	defer wpf(w, "</pre>")

	b, err := Post2Receiver(r, testCommands)

	lge(err)
	lg("msg from Post2Receiver:")
	lg(b.String())

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:18,代碼來源:2_send_cmd.go

示例14: GetIDCardTpl

func GetIDCardTpl(w http.ResponseWriter, r *http.Request, u *User,
	argSignoutURL string, argRedirectSuccess string) string {

	b := new(bytes.Buffer)

	if argRedirectSuccess != "" {
		argRedirectSuccess = "?mode=select&user=wasNil&red=" + argRedirectSuccess
	}

	fmt.Fprintf(b, tplx.ExecTplHelper(IDCardHTML, map[string]interface{}{
		"WidgetURL":  WidgetSigninAuthorizedRedirectURL + argRedirectSuccess,
		"SignOutURL": argSignoutURL,
		"User":       u,
		// "CookieDump": template.HTML(htmlfrag.CookieDump(r)),
	}))

	return b.String()
}
開發者ID:aarzilli,項目名稱:tools,代碼行數:18,代碼來源:tpl_creation.go

示例15: getHomeTpl

func getHomeTpl(w http.ResponseWriter, r *http.Request) *template.Template {

	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	bstpl := tplx.TemplateFromHugoPage(w, r)

	b := new(bytes.Buffer)

	fmt.Fprintf(b, tplx.ExecTplHelper(bstpl, map[string]interface{}{
		// "HtmlTitle":       "{{ .HtmlTitle }}", // this seems to cause problems sometimes.
		"HtmlTitle":       "Member Area",
		"HtmlDescription": "", // reminder
		"HtmlHeaders":     template.HTML(Headers),
		"HtmlContent":     template.HTML(home1 + "\n<br><br>\n" + home2),
	}))

	intHomeTemplate, err := template.New("home").Parse(b.String())
	lg(err)

	return intHomeTemplate

}
開發者ID:aarzilli,項目名稱:tools,代碼行數:22,代碼來源:tpl_creation.go


注:本文中的github.com/pbberlin/tools/net/http/tplx.ExecTplHelper函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。