Documentation ¶
Overview ¶
Package builder 提供编译成 HTML 的相关功能
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder 提供了一个可重复生成 HTML 内容的对象
func New ¶
func New(wfs WritableFS, info, erro *log.Logger) *Builder
New 声明 Builder 实例
wfs 表示用于保存编译后的 HTML 文件的系统。可以是内存或是文件系统, 以及任何实现了 WritableFS 接口都可以; info 在运行过程中的一些提示信息通过此输出,如果为空,则会采用 log.Default(); erro 表示的是在把 Builder 当作 http.Handler 处理时,在出错时的日志输出通道。 如果为空,则会采用 log.Default()。如果不准备其当作 http.Handler 使用,则此值是无用;
type WritableFS ¶ added in v1.3.2
type WritableFS interface { fs.FS // WriteFile 将内容写入文件 // // path 遵守 fs.FS.Open 中有关 path 参数的处理规则。 // 整个函数处理逻辑应该与 os.WriteFile 相同。 // 如果文件父目录不存在,应该要自动创建。 WriteFile(path string, data []byte, perm fs.FileMode) error // Reset 重置内容 // // 该操作会删除通过 WriteFile 添加的文件。 // 原来已经存在的内容,则依然会存在,比如 Dir() 创建的实例, // 就有可能是基于一个已经存在的非空目录,Reset 不应该破坏其原来的结构。 Reset() error }
WritableFS 带有写入功能的文件系统
Click to show internal directories.
Click to hide internal directories.