Skip to content

Instantly share code, notes, and snippets.

@rob-gordon
Created September 11, 2017 20:10
Show Gist options
  • Select an option

  • Save rob-gordon/d21042a5e3c4850a299a63038dd50924 to your computer and use it in GitHub Desktop.

Select an option

Save rob-gordon/d21042a5e3c4850a299a63038dd50924 to your computer and use it in GitHub Desktop.
get partial
function get_partial($path, $args = false) {
/* Set any variables */
if ($args && gettype($args) == 'array') {
foreach($args as $key => $value) {
$$key = $value;
}
}
include(locate_template('partials/'.$path.'.php'));
/* Unset any variables passed for this partial */
if ($args && gettype($args) == 'array') {
foreach($args as $key => $value) {
unset($$key);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment