本文整理汇总了Golang中html/template.Execute函数的典型用法代码示例。如果您正苦于以下问题:Golang Execute函数的具体用法?Golang Execute怎么用?Golang Execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
func main () {
html_t, err := gaml.GamlToHtml(gaml_template_1)
if err != nil {
fmt.Printf("error: %s", err.Error())
}
template,err := template.New("test_template").Parse(html_t)
template.Execute(os.Stdout, "Hello World!")
html_t, err = gaml.GamlToHtml(gaml_template_2)
if err != nil {
fmt.Printf("error: %s", err.Error())
}
template,err = template.New("test_template2").Parse(html_t)
if err != nil {
fmt.Printf("error: %s", err.Error())
}
template.Execute(os.Stdout, People)
html_t, err = gaml.GamlToHtml(gaml_template_3)
if err != nil {
fmt.Printf("error: %s", err.Error())
}
template,err = template.New("test_template3").Parse(html_t)
if err != nil {
fmt.Printf("error: %s", err.Error())
}
template.Execute(os.Stdout, People)
}
开发者ID:a2800276,项目名称:gaml,代码行数:30,代码来源:template.go
示例2: GetTestServer
func GetTestServer() (*httptest.Server, string) {
mux := http.NewServeMux()
stormpathMiddleware := NewStormpathMiddleware(mux, nil)
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
account := stormpathMiddleware.GetAuthenticatedAccount(w, r)
w.Header().Add("Content-Type", "text/html")
template, err := template.New("main").Parse(mainTemplate)
if err != nil {
fmt.Fprint(w, err)
return
}
model := map[string]interface{}{
"account": account,
"loginUri": Config.LoginURI,
"logoutUri": Config.LogoutURI,
}
if account != nil {
model["name"] = account.GivenName
}
template.Execute(w, model)
}))
return httptest.NewServer(stormpathMiddleware), stormpathMiddleware.Application.Href
}
开发者ID:jarias,项目名称:stormpath-sdk-go,代码行数:35,代码来源:web_test.go
示例3: SendEmail
func (s *SmtpServer) SendEmail(email Email) error {
parameters := &struct {
From string
To string
Subject string
Message string
}{
email.From,
strings.Join([]string(email.To), ","),
email.Title,
email.Message,
}
buffer := new(bytes.Buffer)
template := template.Must(template.New("emailTemplate").Parse(emailTemplate))
template.Execute(buffer, parameters)
auth := smtp.PlainAuth("", s.Username, s.Passwd, s.Host)
err := smtp.SendMail(
fmt.Sprintf("%s:%d", s.Host, s.Port),
auth,
email.From,
email.To,
buffer.Bytes())
return err
}
开发者ID:narma,项目名称:golib,代码行数:30,代码来源:smtp.go
示例4: NewContratoStatus
func NewContratoStatus(rw http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
inq_id := getParamToInt(query, "inquilino")
imovel_id := getParamToInt(query, "imovel")
fmt.Println(inq_id, imovel_id)
imovel := model.Db.SelectImovelById(imovel_id)
inq := model.Db.SelectInquilinoById(inq_id)
new_contrato := structs.Contrato{
Data: query["data"][0],
Email: query["email"][0],
Prazo_locacao: query["prazo_locacao"][0],
Inicio_contrato: query["inicio_contrato"][0],
Fim_contrato: query["fim_contrato"][0],
Valor_aluguel: query["valor_aluguel"][0],
Dia_vencimento: query["dia_vencimento"][0],
Imovel: imovel,
Inquilino: inq,
}
fmt.Println(new_contrato)
generateContract(new_contrato, Settings.TEMPLATE_FILE, Settings.OUTPUT_FILE)
if Settings.SEND_EMAIL == "true" {
utils.SendEmail(Settings.EMAIL_ADDRESS, Settings.EMAIL_PASSWORD, new_contrato.Email, "Contrato de Locação", "Contrato de Locação em anexo.", Settings.OUTPUT_FILE)
}
template, _ := template.ParseFiles("template/new_contrato_status.html")
template.Execute(rw, new_contrato)
}
开发者ID:marcelolima,项目名称:leasing_contract_generator,代码行数:29,代码来源:routes.go
示例5: SoggyEngine
func (engine *HTMLTemplateEngine) SoggyEngine(writer io.Writer, filename string, options interface{}) error {
template, err := template.ParseFiles(filename)
if err != nil {
return err
}
return template.Execute(writer, options)
}
开发者ID:dbrain,项目名称:soggy,代码行数:7,代码来源:htmltemplateengine.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng