I am trying to learn the behinds of template system by creating my own and I have hit a bump...
I want to setup my template as follows:
{@layout=layoutname}
{@content}
<p>This is a paragraph</p>
{@endcontent}
But I don't know how to match {@layout=
and get the layout name.
I have tried: if (preg_match('/(\{\@layout=[a-z]+\})+/', $string, $matches)) {
which works ... kind of. I want to check if there are more then 1 layouts loaded to prevent errors in long files and want to count how many $matches I have and return error if more then 1 match is found but instead of getting all found layouts, it returns the same layout twice:
String used:
{@layout=app}
{@layout=main}
{@content}
<h1>{[username]} profile</h1>
<img src="{[photoURL]}" class="photo" alt="{[name]}" width="100" height="100"/>
<b>Name:</b> {[name]}<br />
<b>Age:</b> {[age]}<br />
<b>Location:</b> {[location]}<br />
{@endcontent}
and using that expression I get:
Array ( [0] => {@layout=app} [1] => {@layout=app} )
can someone please help me find my regex?