You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I much prefer the terminology data-list when working with elements that represent a list of items that represent an iterable data structure.
However, when I want to add a single item to the page, such as adding an error message to a form, it made more sense calling it data-template... but the workflow for adding the element back to the page was a bit clunky.
As an example, this is what the code looks like to add an error message to a form:
functiondo_login(
Input$input, // obviously requiredListElementCollection$listElementCollection, // cumbersome name, and overly verbose to useDocumentBinder$binder, // we still need to manually bindHTMLDocument$document, // AND we need the document to pass in to the list element collection :(
):void {
if(!isAuthenticated($input->getString("email", "pass")) {
$el = $listElementCollection->get($document, "error");
$inserted = $el->insertListItem();
$binder->bindKeyValue("error", "Invalid authentication details", $inserted);
}
}
This calls for a new type of templated element, because that code above is stupidly verbose.
The data-remove-unbound attribute will remove the element if it doesn't get anything bound to it; that is, if there isn't a call to $binder->bindKeyValue("error", "something");
So the PHP would look like this:
functiondo_login(
Input$input, // obviously requiredDocumentBinder$binder, // we now only need the binder
):void {
if(!isAuthenticated($input->getString("email", "pass")) {
// only one line required to keep the element in the document:$binder->bindKeyValue("error", "Invalid authentication details");
}
}
The text was updated successfully, but these errors were encountered:
* build: upgrade dom requirement and loosen version range
* docs: update examples
* feature: trim whitespace when there are only template children
closes#363
* maintenance: phpstorm analysis improvements
* feature: remove unbound elements that are marked accordingly
closes#438
* test: ensure element does not get removed after bound
for #438
* feature: use `data-element` attribute for #438
* tweak: remove data-element attribute
I much prefer the terminology
data-list
when working with elements that represent a list of items that represent an iterable data structure.However, when I want to add a single item to the page, such as adding an error message to a form, it made more sense calling it
data-template
... but the workflow for adding the element back to the page was a bit clunky.As an example, this is what the code looks like to add an error message to a form:
This calls for a new type of templated element, because that code above is stupidly verbose.
Here's my initial idea:
The
data-remove-unbound
attribute will remove the element if it doesn't get anything bound to it; that is, if there isn't a call to$binder->bindKeyValue("error", "something");
So the PHP would look like this:
The text was updated successfully, but these errors were encountered: