snippet($file, $data = array(), $return = false)
Embeds a snippet from the snippet folder
-
$file (string)
Filename from the snippets directory -
$data (array or object)
Data to pass to the snippet as variables -
$return (boolean)
Whether to return the result or to output directly -
return (string)
String value when $return is set to true, otherwise no return value
Example
// Include the header snippet
<?php snippet('header') ?>
// Set the $class variable inside the snippet to "blog"
<?php snippet('header', array('class' => 'blog')) ?>
// Return the rendered snippet code
<?php $header = snippet('header', array(), true);
<?php $header = snippet('header', array('class' => 'blog'), true);