DOMtempl

HTML templating that brings you peace

Blog - FAQ

Misc

Has DOMtempl been ever used in production?

Yes, it's fairly mature and had extensive testing.

Is XML OK to use with DOMtempl?

Yeah, sure. I use it for RSS. It's just not mentioned enough in the docs, as the focus is on HTML; sorry for this oversight.

Why doesn't DOMtempl has feature X?

The feature set for DOMtempl was chosen very carefully, for a course of experimenting with different approaches for over 2 years.

The current number of commands was chosen to be both expressive enough to handle all use cases and compact enough to be easily memorizable.

Each DOMtempl data-command has a ruleset for interacting with other DOMtempl commands. Those rules are both code (and branching), and cognitive load, required by the user to understand them. Growing the number of commands, grows those rules exponentially.

Let's keep it simple.

What about 'data-when-not'?

I'll admit, I really like this idea. I resist it because it adds new command.

What about variable variables?

I experimented with this idea and have a branch implementing those for PHP version somewhere. In the end, I'm on the fence, because I'm having trouble reading my own code when it has that much level of hidden indirection. You're no longer reading the template + data, you're reading template + data pointers + (data that is defined somewhere else).

Is there a formal spec?

No, there kinda isn't. I'm also pretty sure there are like 2000 corner cases and questions my docs and refs don't cover :(

Is there a test suite?

Yes, there is, see 'tests' branch of the repository. As far as I know, NO implementation passes ALL the tests. Some minor things, tho, not anything critical.

Which is the reference implementation?

None. All of them have bugs and DOM workarounds in different places.

PHP is closest to ref, JS close second.

The ideal DOMtempl can only be written to a proper DOM API, which weirdly doesn't seem to exist in any environment. Hrm.

That being said, if you compare the code, you'll notice that the algorithm is exactly the same in all 4 implementations, down to function and variable names.