英文:
"Block"-type template functions
问题
使用http/template,是否可以定义一个类似内置的define或range的“块”类型函数?例如,我想创建一个类似下面的函数:
<div class="page">
  {{doThing}}
    这里有大量的文本...
  {{end}}
</div>
我知道可以通过{{ doThing "这里有大量的文本..." }}来实现,但那不是我想要的。
英文:
Using http/template is it possible to define a "block"-type function that work like the built-in define or range? For example, I'd like to make a function that works like:
<div class="page">
  {{doThing}}
    Large amount of text here...
  {{end}}
</div>
I know I can make it work with {{ doThing "Large amount of text here..." }}, but that's not quite what I want.
答案1
得分: 0
无法编写一个类似内置的define或range操作的块类型函数。
英文:
It is not possible to write a block-type function that works like the built-in define or range actions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论