我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Golang:自定义模板功能“捕获”


I want to write template function like Smarty's capture.
How can I capture html inside

{{capture}}
    ...
{{/capture}}

How to do this?

You would do it in the application: Use a template for the HTML snippet you want to capture, render it, save it to a string and use it in subsequent template rendering.

{{define "T1"}}ONE{{end}}
{{define "T2"}}TWO{{end}}
{{define "T3"}}{{template "T1"}} {{template "T2"}}{{end}}
{{template "T3"}}

ONE TWO

近期文章

  • 无法使gdb适用于Go 1.3程序
  • ql golang数据库(ql / cznic)
  • 在Go模板中使用{{}}原始表达式
  • 使用Dokku部署Revel(Golang)
  • Go:Java的CyclicBarrier之类的可重用屏障?
  • 通过tls.Server连接进行读写
  • 有没有成熟的库可以解析电子邮件标题? -走
  • 如何测试事务回滚并在Go lang中提交
  • 使用Golang REST服务中的AngularJS显示JSON字段
  • 从服务器发送JSON需要两次JSON.parse
  • gop的scp客户端中的scp路径
  • Golang-将文件系统嵌入二进制文件; 与库一起使用
  • 尝试使用gdb(和cgdb)调试go(golang)中的程序,但似乎存在问题
  • UDP ping-尝试获取端口无法访问错误
  • Heroku:使用临时文件系统(golang buildpack)时,R14内存错误
  • 与Gingko和Gomega一起使用Withmock
  • Golang Liteide-无法解析动作
  • 如何使LiteIDE显示* big.Int(或您的类型)的用户友好手表字符串?
  • 将结构字段参数传递给函数
  • 将字符串切片try索引方法抽象为所有切片类型

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华