Starting with Go Templates, what does the T indicate in {{T "post_nav_prev"}}

huangapple go评论82阅读模式
英文:

Starting with Go Templates, what does the T indicate in {{T "post_nav_prev"}}

问题

我正在尝试理解Hugo中的Go模板。我发现了这个语法结构{{T "post_nav_prev"}}。我在i18n yaml文件en.yaml中找到了post_nav_prev的定义,但是找不到T是什么或者它在哪里定义的。对于基础知识的欠缺,我感到抱歉。感谢任何指导。

英文:

Trying to understand Go templates in Hugo. I find the subject construct {{T "post_nav_prev"}}. I see post_nav_prev defined in i18n yaml file en.yaml, but can't seem to find what T is or where it is defined. Sorry for the lack of basic knowledge. Thanks for any guidance.

答案1

得分: 3

Tlang.Translate 的别名。

来源:https://gohugo.io/functions/lang/#langtranslate

它在这里定义:https://github.com/gohugoio/hugo/blob/e164834f0aaaf1c58489fab41f5835b66f16b87c/tpl/lang/init.go#L33

英文:

T is an alias for lang.Translate

source : https://gohugo.io/functions/lang/#langtranslate

It define here

huangapple
  • 本文由 发表于 2022年5月18日 21:50:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/72290467.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定