Created
October 8, 2012 14:49
-
-
Save jeffrydegrande/3852929 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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