思源笔记社区正在搭建中,现邀您共建
SiYuan Community is under construction. Join us to co-build.
defaultdefault:default "foo" .Bar.Bar 的计算结果为非空值,则使用该值。但如果为空,则返回 foo。0""[]{}falsenil(即 null)emptyempty 函数会根据给定值是否为空返回 true 或 false。default 部分中列出。empty .Fooif empty .Foo。而是直接使用 if .Foo。coalescecoalesce 函数接受一列值,并返回第一个非空值。coalesce 0 1 21。coalesce .name .parent.name "Matt".name 是否为空。coalesce 将评估 .parent.name 是否为空。.name 和 .parent.name 都为空,则返回 Matt。allall 函数接受一列值,并在所有值均非空时返回 true。all 0 1 2false。all (eq .Request.TLS.Version 0x0304) (.Request.ProtoAtLeast 2 0) (eq .Request.Method "POST")http.Request 是否为 "POST" 方法,并具有 tls 1.3 和 http/2 版本。anyany 函数接受一列值,并在任何一个值非空时返回 true。any 0 1 2true。any (eq .Request.Method "GET") (eq .Request.Method "POST") (eq .Request.Method "OPTIONS")http.Request 的方法是否为 GET/POST/OPTIONS 之一。fromJson, mustFromJsonfromJson 函数将 JSON 文档解码为结构体。mustFromJson 会在 JSON 无效时返回错误。fromJson "{\"foo\": 55}"toJson, mustToJsontoJson 函数将项目编码为 JSON 字符串。mustToJson 会在项目无法以 JSON 编码时返回错误。toJson .Item.Item 的 JSON 字符串表示形式。toPrettyJson, mustToPrettyJsontoPrettyJson 函数将项目编码为漂亮(缩进)的 JSON 字符串。toPrettyJson .Item.Item 的缩进的 JSON 字符串表示形式。toRawJson, mustToRawJsontoRawJson 函数将项目编码为带有未转义 HTML 字符的 JSON 字符串。toRawJson .Item.Item 的未转义的 JSON 字符串表示形式。ternaryternary 函数接受两个值和一个测试值。ternary "foo" "bar" truetrue | ternary "foo" "bar""foo"。ternary "foo" "bar" falsefalse | ternary "foo" "bar""bar"。