Skip to content

Instantly share code, notes, and snippets.

@jeffrydegrande
Created October 8, 2012 14:49
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 jeffrydegrande/3852929 to your computer and use it in GitHub Desktop.
Save jeffrydegrande/3852929 to your computer and use it in GitHub Desktop.
function manifest_to_hash() {
$path = APP_ROOT . "shared/assets/manifest.yml";
$hash = array();
$fp = fopen($path, "r");
while (($line = fgets($fp)) != NULL) {
$line = rtrim($line);
if ($line === "---") continue;
list($key, $value) = explode(":", $line);
$hash[trim($key)] = trim($value);
}
fclose($fp);
return $hash;
}
function asset_path($file, $echo = true) {
global $asset_manifest;
if (!isset($asset_manifest)) {
$asset_manifest = manifest_to_hash();
}
$asset_path = root_url(false) . "/assets/" . $asset_manifest[$file];
if ($echo)
echo $asset_path;
return $asset_path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment