Releases: PhpGt/DomTemplate
Consistency and stricter types
Consistency has been improved with other PHP.Gt repositories, specifically the use of "contains" over "has" to match other DOM APIs.
Type checking has been made safer with the use of the null coalescing operator rather than emitting warnings or throwing errors.
Bugfixes and improvements
- Bindable attributes removed more efficiently
- :empty selector fixed when empty dataset is bound
- Multiple braced parameters per attribute
- Always cast bound data to objects (accepting assoc. arrays)
- Types loosened to allow more compatibility with DOMDocument
- Existing classes are persisted from custom components
Improved data binding
- Do not output
-t
prefix when XPath name used - Carry over classes from source elements when expanding components
- Clone templates to avoid same templates being reused
- Inject data into attribute values using braces
Fragments, templates and components improved
- DocumentFragment::appendHTML allows HTML5 to be appended to the fragment directly
- Fix recursive expandComponents when components are nested
- Looser type checking where document fragments are allowed
- Edge case tests
- t- and c- class prefixes normalised
Components made more flexible
Components behave better when mixed with templates.
Notably, a component can be nested within a template element, and its value will be expanded as soon as the template is used, rather than when the template is rendered to the page. This allows the developer to manipulate the contents of the component on-the-fly.
Bindable class lists
The final planned feature for v1 is now implemented: bindable class lists.
Automatically toggle a class name of an element depending on a truthy value of the dataset.
Improvements to Bindable
- Optional bind keys with question mark parameter
- Allow binding of named templates without specifying name
- Allow templates to be referenced outside of the tree path
- Unit test coverage improved
- CodeSniffer warnings resolved
Feature complete
All originally scoped features are now implemented, but some real world use-cases must be tested before we get close to a production release.
- Invalid bind properties are caught
- Bind attributes are tidied
- Template attributes are tidied
- Templates are removed from document
Template elements built up with bind
- Exceptions thrown when expected bind attribute is not found
- Data binding on existing elements improved
- Todo list test written and passing
Data binding
- Data is bound on existing elements
- Bind function split into in-document and in-template
- More tests