Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip

需要注意的是,该特性并不会影响include模板的内置函数。

使用示例:

1、配置文件

Code Block
languagetoml
[viewer]
    delimiters  =  ["${", "}"]
    autoencode  =  true

...

2、示例代码

Code Block
languagego
package main

import (
	"context"
	"fmt"
	"github.com/gogf/gf/v2/frame/g"
)

func main() {
	result, _ := g.View().ParseContent(context.TODO(), "姓名: ${.name}", g.Map{
		"name": "<script>alert('john');</script>",
	})
	fmt.Println(result)
}

3、执行输出

Code Block
languagexml
姓名: &lt;script&gt;alert(&#39;john&#39;);&lt;/script&gt;

...