KScript 文档
ZH

mime 字段与方法

字段是关于值的一个普通事实,用点号读取,不需要方括号:$value.name。方法会接收参数或执行操作,调用方式为 ->:$value->name(arguments),也可以把值通过管道传入:$value |> name(arguments)。

字段

字段类型说明
.essencestring不含参数的类型与子类型:text/html。
.main_typestring斜杠 / 之前的部分:text/html 中的 text。(->type() 与其他任何值一样,属于 mime。)
.paramsmap以映射形式给出的参数:{ charset: 'utf-8' }。
.subtypestring斜杠 / 之后的部分:text/html 中的 html。

来自 KScript.Core

#mime->is(pattern: string) → bool

当与 text/html、text/* 或 / 匹配时为真。
参数接受
pattern 必需string
示例
<let name="x" type="mime" value="'text/html; charset=utf-8'" />
<echo>{ $x->is('text/*') }</echo>
$x: mime = 'text/html; charset=utf-8'
echo $x->is('text/*')

来自 any 的方法

来自 string 的方法