I have a template in my DB with a styling, created by the user. Because users are generally stupid and also I don’t want them to meddle with php code, I want to insert the actual values into their style before the template is rendered. It’s dynamic values.
So I have things like
<p>Here is your value:</p>
<span id="value"></span>
<p>Enjoy it!</p>
A placeholder for the value. This is probably the easiest way. I can’t/don’t want use jQuery here, but I want something similar.
I’ve seen PHP’s DOMDocument class, which seems to do the trick, with one problem: $dom->saveHTML() seems to be always saving the entire HTML tree. $dom->saveHTML($element) saves just that element, but I have several at once in my template.
Is there a trick to get them all saved without the html stuff around?
saveHTML()saves the element itself and all its children.You can save the body node to save the whole document content:
Or save body’s children one by one: