Scriban 语法速查
3m45s
变量与输出
所有页面数据通过 post.xxx 访问。输出变量时使用 {{ post.title }},避免直接写裸字段。
{{ post.title }}
{{ post.summary }}
条件判断
使用 if/else 进行条件渲染。
{{ if post.tags }}
{{ for tag in post.tags }}
{{ tag }}
{{ end }}
{{ end }}
循环渲染
列表结构用 for 遍历,搭配 for.first/for.last 控制边界。
{{ for item in post.toc }}
{{ item.title }}
{{ end }}
组件引入
自定义组件放在 components/,使用文件名引入。
{{ include 'docsSidebar' }}
常见坑
- 不要在
.sbn中包含<html>/<head>/<body>。 - 链接需要包含
/后缀。 - JSON 属性使用小驼峰命名。
找不到你需要的内容?
联系我们