Skip to content

Instantly share code, notes, and snippets.

@Golpha

Golpha/foo.php Secret

Created March 14, 2016 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Golpha/da55b86c9d7c811a3074 to your computer and use it in GitHub Desktop.
Save Golpha/da55b86c9d7c811a3074 to your computer and use it in GitHub Desktop.
<?php
function parseTemplate($template, array $variables = [], array &$throwBacks = array())
{
$scope = function() use ($variables, $template, &$throwBacks)
{
extract($variables);
ob_start();
$throwBacks = include sprintf('%s/static/%s', __DIR__, $template);
if ( ! is_array($throwBacks) )
{
$throwBacks = (array) $throwBacks;
}
$content = ob_get_clean();
return $content;
};
return $scope();
}
@Golpha
Copy link
Author

Golpha commented Mar 14, 2016

navigation.html -> get_defined_vars()

array(3) {
  ["variables"]=>
  array(0) {
  }
  ["template"]=>
  string(21) "pages/newsletter.html"
  ["throwBacks"]=>
  &array(0) {
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment