具有动态名称的 Golang MergeHTML 模板

问题描述

Go 支持使用模板名称嵌入模板。

const temp1 = `
This is main {{template "sub"}}
`
const temp2 = `
this is child
`

func main() {
    tmp1,_ := template.New("main").Parse(temp1)
    tmp1.New("sub").Parse(temp2)
    tmp1.Execute(os.Stdout,"sub")
}

我 2ant 创建一个库,它有自己的模板,并将呈现作为参数传递的模板

<template>
{{render child template which will be passed dynamically}}
</template>
``

The only solution I Could find was to use `template.HTML`. Is there any better solution?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)