nette-components
БесплатноБез исполняемых скриптовНе проверенInvoke before writing or modifying a Nette component (Control), a component factory or a signal handler, and before any AJAX/snippet code. Use when working…
от nette★ 47 звёзд на GitHubОб этом скилле
Nette Components, Signals and Snippets
A component is a descendant of Nette\Application\UI\Control, and the presenter is itself a Control
(ComponentModel\Component -> Container -> UI\Component -> UI\Control -> UI\Presenter), so
everything below applies to both. Related skills: nette-forms (controls, validation, onSuccess),
nette-architecture (where components live), latte-templates ({control}/{snippet} syntax),
nette-configuration (generated factories), frontend-development (Naja on the JS side).
Component Factories
Any container (presenter or control) creates children lazily through createComponent<Name>():
protected function createComponentPoll(): PollControl
{
return new PollControl($this->items);
}
The factory is never called directly. It fires on first access – $this->getComponent('poll') or the
equivalent $this['poll'] (the ComponentModel\ArrayAccess trait), which is what {control poll} does.
An untouched component is never built.
- The name starts with a lowercase letter.
Container::createComponent()requiresucfirst($name) !== $name, so asking forPollnever reachescreateComponentPoll(). - The factory receives the name as its first argument, and may either return the component or add it
itself with
addComponent(); doing neither throwsNette\UnexpectedValueException. - Names match
#^[a-zA-Z0-9_]+$#D– no hyphen in a name,-is the tree separator:$this['cart-form']means "childformof childcart", nesting to any depth. - Not presenter-only: a
ControldefinescreateComponent<Name>()for its own children the same way. - For components with dependencies, inject a factory (a class or a DI-generated interface) and call it
from
createComponent<Name>()– see nette-configuration forimplement:.
Signals
A signal performs an action on the current page. It calls handle<Signal>() on the component
addressed by the do query parameter (?do=cart-remove); matching is case-insensitive.
public function handleDelete(int $id): void // ?do=delete&id=…
{
$this->facade->delete($id);
$this->redirect('this');
}
Where signals run – after the action phase and canonicalization, before any render
method, not "in the action phase" (the full lifecycle order is in nette-architecture).
Consequence: a handler can prepare data that render<View>() then respects
(if (!isset($this->template->articles)) …).
- A signal cannot target another presenter or action; it re-runs the current request plus the handler.
A missing handler throws
BadSignalException(403 page). - Signal parameters come from the URL and from the POST body, but a URL parameter of the same name wins. They share one namespace with action and persistent parameters.
- A form submit is not a signal.
UI\Form::signalReceived()accepts only the signalsubmitand turns it intoonSubmit/onSuccess; any other signal name on a form throwsBadSignalException. Never writehandleSubmit()for a form – put the logic in anonSuccesshandler (see nette-forms).
Links Inside a Component
In a component template, n:href, {link} and $this->link()/$this->redirect() always mean a
signal of that component, with or without ! – LinkGenerator switches to signal mode as soon as the
link source is not a Presenter.
{* inside a component template *}
<a n:href="click!">signal</a> {* the ! is optional here *}
<a n:href="subcomponent:click!">signal of a child</a>
<a href={plink Home:default}>presenter link</a>
{plink} = presenter link: it compiles to $this->global->uiPresenter->link(...), where {link}
and n:href compile to $this->global->uiControl->link(...). It is not "absolute" and not
"persistent" – an absolute URL comes from the // prefix, which works with {link} too. In PHP the
equivalent is $this->getPresenter()->link('Home:default').
The only non-signal destination inside a component is 'this' (current presenter + action):
$this->redirect('this'). Arguments cannot be passed to this!.
Persistent Parameters
A persistent parameter survives across requests in the URL, automatically, including links generated by other components on the page.
use Nette\Application\Attributes\Persistent;
class ItemList extends Control
{
#[Persistent]
public int $page = 1; // must be public, non-static, typed
}
loadState() writes the URL value into the property and answers a type mismatch with a 404 – override it
for range checks; saveState() is the reverse direction. In links, <a n:href="this page: $page + 1">
changes the value and page: null resets it to the default (drops it from the URL).
Persistent components use the same attribute on the presenter class, listing component names; their persistent parameters then survive across actions and presenters, subcomponents included:
#[Persistent('
Установить nette-components в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл nette-components?
Invoke before writing or modifying a Nette component (Control), a component factory or a signal handler, and before any AJAX/snippet code. Use when working with createComponent<Name>(), $this['name'], handle<Signal>() methods, signal links (n:href="click!", link('click')), {plink} in a component template, persistent parameters (#[Persistent]) and persistent components, redrawControl()/isControlInvalid(), {snippet} and {snippetArea}, dynamic snippets, isAjax() and $this->payload, Multiplier, or the component tree (getComponents(), getComponentTree(), monitor(), lookup(), $onAnchor). Also trigger for "snippet is not redrawing", BadSignalException, or "how do I do AJAX in Nette".
Как установить скилл nette-components?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nette-components запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic