In my last post, I mentioned my ideal of keeping “HTML” generation as operations on a DOM tree, instead of assigning variables to templates and using string substitution. Parse the initial template file, fill it with data, then render it once with safe encoding (where relevant) at the end.
I also know why this approach isn’t as popular: everyone hates the DOM.
Showing posts with label dom. Show all posts
Showing posts with label dom. Show all posts
Saturday, September 5, 2015
Saturday, December 1, 2012
Hairy Escaping Problems (Keep the Pieces 2)
I was just settling in to hack out a Smarty-like template system (or at least an interpreter for it) in a non-PHP language, when my brain went all meta on me. ‘How can I never, ever have to deal with careful manual control over output encoding, ever again?’
Sunday, August 8, 2010
On XML and data formats
In many discussions of XML, there seems to be a faction of programmers who are completely dead-set against XML. They'll insist on JSON, or YAML, or any other cool technology that isn't supported in that 5-year-old version of whatever language your company is still running. The usual complaints leveled against XML-based formats are verbosity and the complexity of the DOM. (Sometimes, leading or trailing whitespace on element contents in pretty-printed XML will bite a project, but this never seems to come up in internet flamewars.)
The really young, or maybe just incurably naive, programmers will even chime in that anything that can be done in XML can be done, or even done better, in JSON. I even thought this once, until I tried to write a generic XML-to-JSON converter, which showed me how wrong I was.
The really young, or maybe just incurably naive, programmers will even chime in that anything that can be done in XML can be done, or even done better, in JSON. I even thought this once, until I tried to write a generic XML-to-JSON converter, which showed me how wrong I was.
Subscribe to:
Posts (Atom)