企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 渲染引擎(Renderer) 渲染引擎用于渲染内容。 ## 概要 ``` hexo.extend.renderer.register(name, output, functiondata, options{}, sync); ``` | 参数 | 描述 | | --- | --- | | `name` | 输入的扩展名(小写,不含开头的 `.`) | | `output` | 输出的扩展名(小写,不含开头的 `.`) | | `sync` | 同步模式 | 渲染函数中会传入两个参数: | 参数 | 描述 | | --- | --- | | `data` | 包含两个属性:文件路径 `path` 和文件内容 `text`。`path` 不一定存在。 | | `option` | 选项 | ## 范例 ### 非同步模式 ``` varrequire'stylus' // Callback hexo.extend.renderer.register('styl''css'functiondata, options, callback{ stylus(data.text).set('filename' });// Promise hexo.extend.renderer.register('styl''css'functiondata, options{ returnnewPromisefunctionresolve, reject{ resolve('test' });}); ``` ### 同步模式 ``` varrequire'ejs' hexo.extend.renderer.register('ejs''html'functiondata, options{ options.filename = data.path; return }, true ```