I have an array containing some content like this:
$content = array(
array(
'classname' => 'nopadding',
'idname' => 'car-volvo',
'title' => 'Volvo'
),
array(
'classname' => 'nomargin',
'idname' => 'car-porsche',
'title' => 'Porsche'
)
);
and I have an HTML file, serving as a template containing this:
<li data-tpl-classname="class" data-tpl-idname="id"><span data-tpl-title="innerHTML"></span></li>
Now I want to use the array together with the HTML file to produce this:
<li class="nopadding" id="car-volvo"><span>Volvo</span></li>
<li class="nopadding" id="car-volvo"><span>Volvo</span></li>
I'm looking to write a general function that takes HTML files like the one above, looks for data-tpl-
attributes and fills with the content from the array.
How can I achieve this? Is SimpleXML the way to go?