Documentation
¶
Overview ¶
Package slice2table: Convert Go struct slice to HTML table with customizable rendering options Features automatic field extraction, tag-based column naming, and flexible HTML table generation Supports custom tag names and intelligent field filtering to create clean table presentation Provides seamless struct-to-HTML transformation with built-in HTML escaping
slice2table: 将 Go 结构体切片转换为 HTML 表格,具有可定制的渲染选项 具有自动字段提取、基于标签的列命名和灵活的 HTML 表格生成 支持自定义标签名称和智能字段过滤,实现清洁的表格展示 通过内置 HTML 转义提供无缝的结构体到 HTML 转换并确保安全性
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenTable ¶ added in v0.0.6
GenTable generates HTML table with custom options and advanced configuration Extracts column names from struct tags and creates formatted table rows Applies HTML escaping to protect against XSS and combines header with data rows
GenTable 使用自定义选项和高级配置生成 HTML 表格 从结构体标签提取列名并创建格式化的表格行 应用 HTML 转义确保安全性并将表头与数据行组合
Types ¶
type Options ¶
type Options struct {
TagName string // Struct tag name when extracting column headers // 提取列标题时使用的结构体标签名
}
Options represents configuration settings when generating HTML tables Contains customizable parameters which control table rendering Supports tag-based column naming and extensible option patterns
Options 代表 HTML 表格生成的配置设置 包含用于控制表格渲染行为的可定制参数 支持基于标签的列命名和可扩展的选项模式
func NewOptions ¶
func NewOptions() *Options
NewOptions creates default options configuration when generating tables Sets "table" as the default tag name when processing struct fields Returns configured options which enable table generation operations
NewOptions 为表格生成创建默认选项配置 将 "table" 设为结构体字段处理的默认标签名 返回准备用于表格生成操作的配置选项
func (*Options) WithTagName ¶
WithTagName sets custom tag name when extracting column headers Allows dynamic configuration of struct tag when naming columns Returns modified options to enable method chaining
WithTagName 设置用于列标题提取的自定义标签名 允许动态配置用于列命名的结构体标签 返回修改后的选项以支持方法链式调用
Directories
¶
| Path | Synopsis |
|---|---|
|
Package struct2table: Single struct to HTML table conversion tool Provides convenient functions when converting individual struct instances to HTML tables Leverages slice2table package for core functionality with single-item slice wrapping Simplifies table generation workflow for single object display scenarios
|
Package struct2table: Single struct to HTML table conversion tool Provides convenient functions when converting individual struct instances to HTML tables Leverages slice2table package for core functionality with single-item slice wrapping Simplifies table generation workflow for single object display scenarios |