how do i convert my includes to {sidebar} or strings to {whatever}?
Without using any skinning engine. i feel like this is a newb question lol
how do i convert my includes to {sidebar} or strings to {whatever}?
Without using any skinning engine. i feel like this is a newb question lol
If you take this ‘template’…
<html>
<head>
<title>Demo</title>
</head>
<body>
<div id="content">
{content}
</div>
<div id="sidebar">
{sidebar}
</div>
</body>
</html>
…and add apply this piece of code to it…
<?php
preg_replace(
'~{([a-z]+)}~i',
'<?php include \\'$1.php\\'; ?>',
$subject
);
?>
…it converts it to this…
<html>
<head>
<title>Demo</title>
</head>
<body>
<div id="content">
<?php include 'content.php'; ?>
</div>
<div id="sidebar">
<?php include 'sidebar.php'; ?>
</div>
</body>
</html>
…you can then pass this to [fphp]eval/fphp for PHP to do its magic with…
<?php
echo eval(sprintf(
'?>%s<?php',
preg_replace(
'~{([a-z]+)}~i',
'<?php include \\'$1.php\\'; ?>',
$subject
)
));
?>
<?php echo $sidebar ?>
It’s not a noob question, it’s noobs that maintain you need to do that in the first place. If you have need of a templating system for reasons other than “using curly braces” that’s another story.