Repository navigation
API reference
This page is a compact reference for the public API of the library.
For walkthroughs and examples, use the earlier pages in the guide.
registerBindFilter(BindFilter $filter): voidbindValue(mixed $value, null|string|Element $context = null): voidbindKeyValue(string $key, mixed $value, null|string|Element $context = null): voidbindData(mixed $kvp, null|string|Element $context = null): voidbindTable(mixed $tableData, null|string|Element $context = null, ?string $bindKey = null): voidbindList(iterable $listData, null|string|Element $context = null, ?string $templateName = null): intbindListCallback(iterable $listData, callable $callback, null|string|Element $context = null, ?string $templateName = null): intcleanupDocument(): void
ComponentBinder exposes the same binding methods as DocumentBinder, but confines all binding to one expanded component element.
Extend GT\DomTemplate\BindFilter and define public instance methods named name($value) for use as key|name in binding expressions.
setDependency(object $dependency): voidgetDependency(class-string<T> $class): ?T
Register shared provider instances with registerBindFilter(). Later providers override matching filter names; earlier providers remain available for other names. See Bind filters for chaining, sharing and error handling.
Most binding methods accept:
-
nullfor the whole document or whole component - an
Elementinstance - a selector
string
If the selector string does not match, DomTemplate throws ContextElementNotFoundException.
Suitable for bindValue and bindKeyValue:
- strings
- integers
- floats
- booleans
-
Stringableobjects - callables returning a bindable value
Suitable for bindData:
- associative arrays
- objects with public properties
- objects with
#[Bind]or#[BindGetter] - objects with
asArray()
Suitable for bindList and bindListCallback:
- arrays
IteratorIteratorAggregateArrayIterator- iterable objects
Suitable for bindTable:
- row-oriented arrays with a heading row
- associative row lists
- heading => value-list maps
- double-header structures
- traversable equivalents
ComponentExpander::expand(?Element $context = null): arrayPartialExpander::expand(?Element $context = null, ?DocumentBinder $binder = null): arrayPartialContent::getContent(string $name, string $extension = "html", ?string $src = null): stringPartialContent::getHTMLDocument(string $name): HTMLDocument
data-bind:*data-listdata-templatedata-bind:listdata-bind:tabledata-table-keydata-rebinddata-elementdata-bind-debugdata-list-keep-templatedata-partial
ContextElementNotFoundExceptionIncompatibleBindDataExceptionInvalidBindPropertyExceptionListElementNotFoundInContextExceptionIncorrectTableDataFormatTableElementNotFoundInContextExceptionComponentDoesNotContainContextExceptionPartialContentDirectoryNotFoundExceptionPartialContentFileNotFoundExceptionPartialInjectionPointNotFoundExceptionPartialInjectionMultiplePointExceptionCommentIniInvalidDocumentLocationExceptionCyclicRecursionException
That is the end of the main guide. If you want to jump back into the walkthrough flow, return to Home.
PHP.GT/DomTemplate is a separately maintained component of PHP.GT/WebEngine.