element-html-builder
БесплатноБез исполняемых скриптовНе проверенElement is a zero dependency library to efficiently generate HTML, without templates in Go
Об этом скилле
Element - AI Agent Documentation
Programmatic HTML generation in Go without templates.
Overview
Element is a zero-dependency Go library that generates HTML programmatically by leveraging Go's natural function execution order. Instead of templates, you write Go code that mirrors HTML's tree structure.
Benefits
- You never leave the safety, speed, and familiarity of Go
- Compiles single-pass with the rest of your Go program -- no extra annotations or build steps
- All of Go is available at any point in your code
- Zero dependencies
- Buffer pools and component caching for super-high traffic situations
- Go's formatting naturally follows the HTML tree structure
- Deterministic output: attributes render in the order you pass them
Installation
go get -u github.com/rohanthewiz/element
General Strategy
- Write the opening tag with attributes
- Render the children and closing tag
Core Concepts
The Builder Pattern
All HTML generation flows through a Builder instance. The builder maintains an internal buffer where tags are written immediately upon method calls.
Immediate Tag Writing
Key Insight: When you call a builder method like b.Div(), the opening tag <div> is written immediately to an internal buffer. The returned element must be terminated with R(), T(), or F() to write the closing tag.
b := element.NewBuilder()
b.Div("id", "container") // "<div id="container">" is NOW in the buffer
// The element is returned, waiting for termination
Go's function argument evaluation order means children are processed (and their tags written) before the parent's R() closes the parent tag. This is what makes nested structures work correctly.
Terminate all tags
Every non-self-closing element must be terminated with R(), T(), or F(). Self-closing elements like Br, Img, Input, Hr, and Meta don't require termination, but to keep things consistent, close these tags with a sole R() or T().
Basic Usage
Creating a Builder
import "github.com/rohanthewiz/element"
// Standard creation
b := element.NewBuilder()
// Shorthand (equivalent)
b := element.B()
// From pool (for high-throughput HTTP handlers)
b := element.AcquireBuilder()
defer element.ReleaseBuilder(b)
Deprecated:
element.Vars(),element.V(),b.Funcs(),b.Vars(),b.V()are deprecated. Useelement.B()orelement.NewBuilder()instead.
Simple Elements
b := element.B()
// Element with text content
b.P().T("Hello, World!")
// Output: <p>Hello, World!</p>
// Element with children
b.Div().R(
b.P().T("First paragraph"),
b.P().T("Second paragraph"),
)
// Output: <div><p>First paragraph</p><p>Second paragraph</p></div>
// Empty element
b.Div().R()
// Output: <div></div>
// Get the HTML string
html := b.String()
Complete Page Example
b := element.B()
// b.Html() automatically prepends <!DOCTYPE html> — no separate DOCTYPE needed
b.Html().R(
b.Head().R(
b.Title().T("My Page"),
b.Meta("charset", "utf-8").R(),
),
b.Body().R(
b.DivClass("container").R(
b.H1().T("Welcome"),
b.P().T("Hello from Element!"),
),
),
)
html := b.String()
Building with Multiple Functions
func main() {
b := element.B()
b.DivClass("container").R(
b.H2().T("Section 1"),
generateList(b),
)
fmt.Println(b.Pretty())
/* // Output:
<div class="container">
<h2>Section 1</h2>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
*/
}
func generateList(b *element.Builder) (x any) { // we don't care about the return
// Everything is rendered in the builder immediately!
b.Ul().R(
b.Li().T("Item 1"),
b.Li().T("Item 2"),
)
return
}
API Reference
Builder Creation
| Function | Description |
|---|---|
element.NewBuilder() |
Create a new builder |
element.B() |
Shorthand for NewBuilder() |
element.AcquireBuilder() |
Get builder from pool (high-throughput) |
element.ReleaseBuilder(b) |
Return builder to pool |
Termination Methods
| Method | Use Case | Example |
|---|---|---|
R(children...) |
Elements with children or empty | b.Div().R(b.P().T("hi")) |
T(strings...) |
Text-only content you authored — written verbatim, NOT escaped | b.P().T("Hello") |
TE(strings...) |
Text-only content from anywhere else — HTML-escaped | b.Td().TE(user.Name) |
F(format, args...) |
Formatted text (like fmt.Sprintf) — NOT escaped | b.P().F("Count: %d", 42) |
Escaping: T vs TE
T() and F() write their arguments verbatim
Установить element-html-builder в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл element-html-builder?
Element is a zero dependency library to efficiently generate HTML, without templates in Go
Как установить скилл element-html-builder?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл element-html-builder запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic