Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

datapages-templates

БесплатноБез исполняемых скриптовНе проверен

Write Templ templates for a Datapages app: the generated href and action helpers, their options, attribute syntax, Web Components and Templ pitfalls. Read…

romsharkот romshark★ 122 звезды на GitHub

Об этом скилле

Templates

Read datapages first for the build loop, hard rules and naming conventions.

A Templ component implements datapages.Component, so handlers can return it. Run templ generate to compile .templ files to _templ.go. Datapages does not run this command. Templ docs: https://templ.guide/llms.md

Return application HTML as a Templ datapages.Component. Do not render it into a datapages.File: its bytes bypass Templ's contextual escaping and the Datapages template linter.

href: links

The generated href package has 1 function for each page, named after its page type. Query structs are named href.Query<PageType>. Zero-value fields are omitted from the URL.

<a href={ href.PageIndex() }>Home</a>
<a href={ href.PagePost(post.Slug) }>{ post.Title }</a>
<a href={ href.PageMessages(href.QueryPageMessages{Chat: chatID}) }>Messages</a>
<a href={ href.Asset("logo.svg") }>Logo</a>

The linter rejects a hardcoded root-relative, relative, query-only or empty href. It also rejects javascript:. Literal https://, mailto:, tel:, #frag and //cdn.example.com values are valid. Use href.External(url) for an external URL computed by the app.

Inside href={ ... }, use an href package call, string literal or constant. The linter rejects variables and other calls, including fmt.Sprintf and templ.SafeURL, because it cannot resolve them.

A GETXXX action, which answers with a datapages.File, has a URL builder that is a method of its owner: (*App).GETImage becomes href.App.Image(name), PageDoc.GETExport becomes href.PageDoc.Export(id). href.PageDoc(id) still builds the URL of the page. Pass a query value from the constructor next to the builder, as href.App.Image(name, href.App.ImageQuery(width)). Use these builders in src and href, such as href.App.Image(img.Name) for an image or href.PageDoc.Export(doc.ID) for a download link. The action package has no helper for a GET action: a browser loads it by URL.

action: Datastar actions

An action helper is action.<Owner>.<Name>.<METHOD>(...). Owner is the page type or App. PageLogin.POSTSubmit becomes action.PageLogin.Submit.POST(). (*App).POSTSignOut becomes action.App.SignOut.POST(). The helper returns the complete @post('/...') expression. After datapages gen, read the generated datapagesgen/action package for exact signatures.

<button data-on:click={ action.PageLogin.Submit.POST() }>Submit</button>
<button data-on:click={ action.PagePost.SendMessage.POST(slug) }>Send</button>
<button data-on:click={ action.App.SignOut.POST() }>Sign out</button>

A page action can be used only in that page's template. The linter rejects action.PageA.X.POST() in page B. App actions can be used on any page. Put an action expression in a Datastar action attribute, not in an href.

Every function takes variadic modifiers. Never hand-write the options object.

modifier argument
action.WithContentType action.ContentTypeJSON, action.ContentTypeForm
action.WithSelector CSS selector of the form to send
action.WithFilterSignals include and exclude regexes, exclude may be empty
action.WithHeaders map[string]string
action.WithOpenWhenHidden bool
action.WithPayload raw JavaScript expression
action.WithRetry action.RetryAuto, RetryError, RetryAlways, RetryNever
action.WithRetryInterval, WithRetryScaler, WithRetryMaxWaitMs, WithRetryMaxCount numbers
action.WithRequestCancellation action.RequestCancellationAuto, ...Cleanup, ...Disabled
action.WithRequestCancellationController expression holding an AbortController
action.WithBefore, action.WithAfter JavaScript prepended or appended, joined with "; "
action.WithOption raw key and value for anything the helpers miss

Each modifier returns action.Option. Collect conditional modifiers in an []action.Option and pass opts.... Use this alias instead of importing runtime/actionexpr.

Pass arguments in this order: path variables in route order, the query value from <METHOD>Query(...), then modifiers. The query type is unexported. Create it with the generated constructor.

<button data-on:click={ action.PageMessages.Read.POST(
	action.PageMessages.Read.POSTQuery(msg.ID),
) }>Mark read</button>

Forms

Use a Datastar submit action to keep Enter-to-submit and browser validation:

<form
	data-signals:email="''"
	data-signals:password="''"
	data-on:submit__prevent={ action.PageLogin.Submit.POST() }
>
	<input type="email" data-bind="email" required/>
	<input type="password" data-bind="password" required/>
	<button type="submit">Sign in</button>
</form>

data-bind="email" puts the signal name in the attribute value. HTML lowercases attribute names, so use this form for camelCase signals. For live validation, add data-on:input__debounce.300ms to an input and cal

Полный SKILL.md на GitHub

Установить datapages-templates в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл datapages-templates?

Write Templ templates for a Datapages app: the generated href and action helpers, their options, attribute syntax, Web Components and Templ pitfalls. Read with the datastar skill.

Как установить скилл datapages-templates?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл datapages-templates запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить datapages-templates с