Bind dynamic data to reusable HTML components.
MIT License
Bot releases are visible (Hide)
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.4.0...v3.4.1
Published by g105b 9 months ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.3.0...v3.4.0
Published by g105b 12 months ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.2.3...v3.3.0
Published by g105b about 1 year ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.2.2...v3.2.3
Published by g105b over 1 year ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.2.1...v3.2.2
Published by g105b over 1 year ago
This release introduces a helper attribute, data-element
, which can be used to remove unbound elements from the document. Documentation here: https://github.com/PhpGt/DomTemplate/wiki/automatically-remove-unbound-elements
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.2.0...v3.2.1
Published by g105b over 1 year ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.1.5...v3.2.0
Published by g105b almost 2 years ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.1.4...v3.1.6
Published by g105b almost 2 years ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.1.4...v3.1.5
Published by g105b about 2 years ago
This minor patch release bumps the Dom version, but loosens the semver range as defined by Composer. This will allow future minor releases of Dom to be included by DomTempalte without having to make a new release.
Published by g105b over 2 years ago
Full Changelog: https://github.com/PhpGt/DomTemplate/compare/v3.1.2...v3.1.3
Published by g105b over 2 years ago
A minor patch release to stabalise the dependency on php.gt/dom
Published by g105b over 2 years ago
The bug in PHP's XML implementation deallocates the Text node from memory, even though it might be referenced later. This patch release includes a number of hacky fixes to resolve this downstream, which is a good solution before the PHP bug is fixed.
Published by g105b over 2 years ago
What's changed:
In this minor release, classes of the application can now take advantage of PHP 8.1's new readonly
keyword. Any properties that are marked as public readonly
will be exposed as Bindable values now, removing a lot of boilerplate code on Model classes.
Example:
// Model class:
class PersonModel {
public function __construct(
public readonly string $id,
public readonly string $name,
public readonly int $age,
) {}
#[BindGetter]
public function getAgeStatus():string {
return $this->age >= 18
? "adult"
: "minor";
}
}
// Page code:
function go(Input $input, DocumentBinder $binder, PersonRepository $personRepo):void {
$binder->bindData($personRepo->getById($input->getString("id"));
}
<!-- Page view -->
<div class="user-profile">
<h1 data-bind:text="name">User name<h1>
<img src="/asset/img/user-profile/{{id}}.jpg" alt="{{name}}'s user profile" />
<p>This user is marked as <span data-bind:text="ageStatus">Age Status</span></p>
</div>
Published by g105b over 2 years ago
The major change in this release is the switch to phpgt/dom v4, which now extends the native DOMDocument rather than using a Facade pattern. This greatly improves efficiency.
Changes in functionality also include:
data-rebind
attribute is presentFull Changelog: https://github.com/PhpGt/DomTemplate/compare/v2.2.4...v3.0.0
Published by g105b over 2 years ago
Example: <a href="/path/to/{{project}}/with/{{another}}/attribute/placeholder">
- any attribute can now contain multiple placeholders.
Example: Hello, {{name ?? you}}!
PHP 9 will introduce a lot more strict typing, and 8.1 has started emitting deprecation notices. These have all been addressed in this release.
When template elements have more than one similar siblings, the correct next sibling is remembered, and the template element is inserted in the correct position.
Similarly to above, when two or more template elements have similarly-addressed parents, the template element is now always added to the correct one.
Published by g105b over 2 years ago
The functionality added in the previous release has been moved to be implemented and tested within PHP.Gt/Dom so other projects can take advantage of the functionality, without using DomTemplate.
Published by g105b over 2 years ago
Along with some dependency upgrades, the extra functionality introduced in this release allows an HTMLSelectElement to have its value bound, so the relevant HTMLOptionElement is selected. This works using the value attribute whether or not the option has a value - without a value, the textContent of the option will be used.
Published by g105b almost 3 years ago
In this minor patch release, there are two improvements:
data-template-key
are removed during the cleanBindAttributes()
call.Published by g105b almost 3 years ago
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:
<th>
elements that don't match any bound data are preserved.<tr>
elements can be marked with data-template
to add pre-templated row shapes for advanced designs.