How to truncate a string in a Golang template

后端 未结 7 598
轮回少年
轮回少年 2021-01-01 09:16

In golang, is there a way to truncate text in an html template?

For example, I have the following in my template:

{{ range .SomeContent }}
 ....
             


        
7条回答
  •  再見小時候
    2021-01-01 10:08

    You can use slice from the documentation. The below sample must work :

        {{ slice .Content  0 25}}
    

提交回复
热议问题