Skip to content

Releases: PhpGt/DomTemplate

Upgrade dom requirement and loosen version range

24 Jul 19:29
7b82294
Compare
Choose a tag to compare

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.

ReadOnly property bugfix

14 Jul 11:02
b7e1835
Compare
Choose a tag to compare

What's Changed

  • Build(deps-dev): bump phpstan/phpstan from 1.8.0 to 1.8.1 by @dependabot in #360
  • 361 bugfix by @Tom-Clare in #362

New Contributors

  • @Tom-Clare made their first contribution in #362

Full Changelog: v3.1.2...v3.1.3

Stabalise dependencies

12 Jul 19:15
50155c5
Compare
Choose a tag to compare

A minor patch release to stabalise the dependency on php.gt/dom

Temporary fix for PHP XML bug 81506

12 Jul 18:52
7dfc852
Compare
Choose a tag to compare

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.

Support for Read Only properties

12 Jul 11:08
1075f8d
Compare
Choose a tag to compare

What's changed:

  • ReadOnly properties act as bind getters by default by @g105b in #355

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>

Native DOMDocument extension

02 Jul 10:05
4aabdd1
Compare
Choose a tag to compare

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:

  • cyclic recursion in partials is now handled
  • binding of data only occurs once per bind, unless the data-rebind attribute is present

Full Changelog: v2.2.4...v3.0.0

Minor bugfixes & PHP 8.1 compatibility

14 Mar 17:36
7c8e6ba
Compare
Choose a tag to compare

fix: bind multiple attribute placeholders #327

Example: <a href="/path/to/{{project}}/with/{{another}}/attribute/placeholder"> - any attribute can now contain multiple placeholders.

290 default placeholder #328

Example:

Hello, {{name ?? you}}!

fix: resolve deprecation notices #329

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.

fix: insert template before correct element #330

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.

Identify template parents when there are ambiguous XPath selectors #337

Similarly to above, when two or more template elements have similarly-addressed parents, the template element is now always added to the correct one.

Move responsibility of HTMLSelectElement::$value to PhpGt/Dom

30 Jan 16:26
d8ea73c
Compare
Choose a tag to compare

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.

Select binding by value

30 Jan 14:50
822e7b3
Compare
Choose a tag to compare

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.

Binding tweaks

21 Nov 12:31
a039790
Compare
Choose a tag to compare

In this minor patch release, there are two improvements:

  • Table bind attributes like data-template-key are removed during the cleanBindAttributes() call.
  • Strings that contain names of inbuilt PHP functions are not treated as "callable" types when binding values.