Skip to content

Instantly share code, notes, and snippets.

@rakotomandimby
Last active August 29, 2015 14:02
Show Gist options
  • Save rakotomandimby/7871892eb5b15616b7f4 to your computer and use it in GitHub Desktop.
Save rakotomandimby/7871892eb5b15616b7f4 to your computer and use it in GitHub Desktop.
<?php
function retournerListeVariables($template = "")
{
$listeVariables = array();
if (file_exists($template)) {
$content = file_get_contents($template);
if (preg_match_all("/{{(.*?)}}/si", $content, $aux)) {
$listeVariables = $aux[1];
}
}
}
return $listeVariables;
}
print_r(retournerListeVariables(__DIR__ . '/head.txt'));
?>
Ny ao anatin'ilay template "head.txt" ito:
<!DOCTYPE html>
<html>
<head>
<meta charset='{{ charset }}'/>
<link rel="icon" type="image/{{ extension_favicon }}" href="{{ path_favicon }}" />
{{ stylesheet }}
<title>{{ title }}</title>
</head>
<body>
Dia ny tiako ho azo ito:
Array
(
[0] => charset
[1] => extension_favicon
[2] => path_favicon
[3] => stylesheet
[4] => title
)
Ny avoakan'ilay fonction nefa ito:
Array
(
[0] => charset
[1] => extension_favicon }}" href="{{ path_favicon
[2] => stylesheet
[3] => title
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment