Releases: PhpGt/DomTemplate
Improvements to table binding with existing content
When a <table>
element already exists on the page, it would be useful to utilise the contents of the table, retaining parts of it as a template when binding.
This minor release introduces improvements to help this case:
- Existing
<th>
elements that don't match any bound data are preserved. - Bound data that doesn't match any existing headers is discarded.
- Importantly: existing
<tr>
elements can be marked withdata-template
to add pre-templated row shapes for advanced designs.
Tidying up
The following tweaks have been made to this minor patch release:
null
values can now be bound everywhere, without an exception being thrown.- Internally, the term
Modular
has been renamed toPartial
to reflect the actual usage and documentation. - Another terminology change,
cleanBindAttributes
is renamed tocleanDatasets
to better reflect what the function does. - Examples are added to the source code for helping developers get used to the library.
BindList improvements
Namespace standardisation
In this patch release:
Full Changelog: v2.1.0...v2.1.1
Callbacks to bindList, performance improvements, BindGetter and more!
This release is packed with small updates:
bindListCallback
is introduced that allows a callback function to be called on each iteration of the binding of a list, allowing you to mutate the data per element, along with manually tweaking the templatedHTMLElement
.BindableCache
is introduced that significantly increases the speed of usingBind
attributes.- Wherever a bindable object is used, if it has an
asArray
function, it will always be called. - It's now possible to leave a custom component empty without an exception being thrown.
- Overall, unit tests have been strengthened significantly.
BindData objects
In this minor patch release, bindData()
will now check for all objects' Bind
attribute, adding to the flexibility of throwing an object to a Document for binding to the HTML.
DOM Facade release (v2)
This release introduces no extra functionality, but changes the model in which the DOM is used, and how data is bound.
The major upgrade is that DOM v3 is now used, meaning that the DOM API is now more consistent with the W3C specification. With that, there are no longer any templating methods added to the DOM - instead there are specific classes that are used to bind data in different ways to different types of element. This is not only more readable, but enhances maintainability in your code by utilising the concept of dependency injection.
Have fun, and stay productive!
Github Actions
This patch release includes two improvements:
-
CI is handled by Github Actions now - you can check out the build history at https://github.com/PhpGt/Cli/actions
-
PHPStan level 6 has been applied to the code, meaning certain type hints have been improved for greater readability and future maintainability.
September 2020
The following improvements have been made in this release:
- Docblock improvements to resolve the issue of nested properties losing their DomTemplate extensions (for example
$document->getElementById("test")->parentNode->nextElementSibling
should still beGt\DomTemplate\Element
, but was sometimes indicatingGt\Dom\Element
. - Dropped CircleCI for Github Actions - now everything is in once place (still to do: code quality scoring, currently handled by Scrutinizer)
- Bind attributes are removed in bulk at the end of the page render, which slightly improves performance, but mainly catches the error where not all attributes were removed.
_bindNames
implemented, allowing form elements to have their values bound by their names.
Bind keys of key-value-pairs to templates using unnamed bind parameters
Along with a dependency bump, this release brings the ability to bind the key of a key-value-pair data structure (such as an associative array) to a template element, with unnamed bind parameters.
Using the _key
bind parameter will bind whatever the key is in a key-value-pair iterator. Nice for passing around associative arrays.
An example:
<ul>
<li data-template>
Name: <span data-bind:text="_key">Person Name</span>,
Age: <span data-bind:text>0</span>
</li>
</ul>