DomTemplate

Bind dynamic data to reusable HTML components.

MIT License

Downloads
6.3K
Stars
17
Committers
5

Bot releases are hidden (Show)

DomTemplate - Boolean attribute binding

Published by g105b about 5 years ago

For attributes that don't have a value, like disabled, selected, checked, etc. a new bind rule is added in this release, meaning the attribute will be added if a boolean condition is met.

The attribute value is marked with a preceding question mark. For example: <input type="checkbox" data-bind:checked="?isChecked" />

Small but powerful when working with large repeating datasets.

Have fun and stay productive!

DomTemplate - Efficiency improvement

Published by g105b about 5 years ago

This release changes the internal mechanism for binding lists to the DOM. Rather than appending Elements to the DOM tree in-place, a list is built up in a separate DocumentFragment, and once complete, the fragment is appended to the ParentNode, greatly improving page render speeds on complex documents with many nodes.

Another efficiency improvement is the addition of data-bindparameter` attribute, which now must be added to any Element that will have its parameters bound inline, using curly braces. This is a small backwards breaking change, hence the minor version increment, as before any parameters containing curly braces would be automatically bound.

DomTemplate - Update DOM dependency

Published by g105b about 5 years ago

This release introduces the fixes made to the Dom repository upstream.

DomTemplate - DataBindMapper and DataBindGetter interfaces

Published by g105b about 5 years ago

The introduction of the two new interfaces DataBindMapper and DataBindGetter allow the developer to state that a class can be used in the DomTemplate bind functions, without having to expose the data as public properties.

DataBindMapper defines a function, dataBindMap which must return an associative array, and will be called in the bind process.

DataBindGetter does not define any functions, but instead indicates to DomTemplate that the class should have its get* functions called for any keys that are bound. For example, binding a key of id will try to call the getId function on the class.

DomTemplate - Less strict types

Published by g105b over 5 years ago

With a small bump of dependencies, this release contains only one minor change: the ability to pass bound keys and values as null. When a null value is bound, it is treated as an empty string.

DomTemplate - Usability improvements

Published by g105b over 5 years ago

Typehints have been made less strict in some areas, so objects or associative arrays can be used as the data.

The bind function has been introduced as an alias to the bindKeyValue function.

In the binding of list items, the data is bound to the nodes after they are inserted into the DOM to avoid incorrect referencing issues after complete.

DomTemplate - Stable release (with bindable DOM)

Published by g105b over 5 years ago

Before a stable release could be made, the way that data was bound to the DOM needed to be addressed. Currently (v0.6.x) this was too complex, because no matter what type of data you had, everything was bound to the DOM through the Element::bind() function. That included key value pair storage, lists, and if there was data that needed to be bound to a nested list it was impossible to bind without iterating over it yourself.

The stable release introduce introduces, amongst a generous amount of bugfixes and test hardening, the addition of the following new functions:

  • bindKeyValue
  • bindData
  • bindList
  • bindNestedList

They should be self-explanatory now, and depending on the data that you wish to bind to the page, should be very obvious as to which function you should be calling.

Have fun, and stay productive!

DomTemplate - DocBlocks

Published by g105b over 5 years ago

Throughout the repository, all classes have received PHP Doc Block comments to describe to IDEs what types are being returned by inherited functions. This is required because of the use of DOMDocument::registerNodeClass, which has some unusual side effects with the way classes are inherited in the DOM.

DomTemplate - Improvements to tests

Published by g105b over 5 years ago

PHPUnit 8 has been introduced and tests adjusted accordingly. Continuous Integration services are now updated to work with the latest version of PHP.

DomTemplate - Consistency and stricter types

Published by g105b almost 6 years ago

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.

DomTemplate - Bugfixes and improvements

Published by g105b about 6 years ago

  • 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
DomTemplate - Improved data binding

Published by g105b over 6 years ago

  • 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
DomTemplate - Fragments, templates and components improved

Published by g105b over 6 years ago

  • 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
DomTemplate - Components made more flexible

Published by g105b over 6 years ago

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.

DomTemplate - Bindable class lists

Published by g105b almost 7 years ago

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.

DomTemplate - Improvements to Bindable

Published by g105b almost 7 years ago

  • 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
DomTemplate - Feature complete

Published by g105b almost 7 years ago

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
DomTemplate - Template elements built up with bind

Published by g105b almost 7 years ago

  • Exceptions thrown when expected bind attribute is not found
  • Data binding on existing elements improved
  • Todo list test written and passing
DomTemplate - Data binding

Published by g105b almost 7 years ago

  • Data is bound on existing elements
  • Bind function split into in-document and in-template
  • More tests
DomTemplate - Introduce Bindable trait

Published by g105b almost 7 years ago

Bindable introduces the next feature: dynamic data binding.