Created
October 18, 2012 10:13
Revisions
-
Tiago Dias revised this gist
Oct 18, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,12 +33,13 @@ function javascript_include_tag($assets, $options = array()) function stylesheet_link_tag($assets, $options = array()) { $default = array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'all'); return assets_include_tag($assets, '<link href="%s"%s />', array_merge($default, $options)); } // Examples of usage: // <?php echo stylesheet_link_tag(array('stylesheets/all.css')) ?> // <?php echo javascript_include_tag(array('javascripts/all.js')) ?> // <?php echo javascript_include_tag(array('javascripts/search.js'), array('charset' => 'UTF-8')) ?> ?> -
Tiago Dias revised this gist
Oct 18, 2012 . 1 changed file with 15 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,32 +2,39 @@ define('_ROOT', dirname(realpath(__FILE__))); function assets_include_tag($assets, $tmpl, $options) { if (empty($assets)) { return false; } $assetOptions = ''; $assetOutput = array(); foreach ($options as $key => $value) { $assetOptions .= " {$key}=\"{$value}\""; } foreach ($assets as $asset) { $filepath = _ROOT . "/{$asset}"; if (is_file($filepath)) { array_push($assetOutput, sprintf($tmpl, "{$asset}?v=" . filemtime($filepath), $assetOptions)); } } return implode(PHP_EOL, $assetOutput) . PHP_EOL; } function javascript_include_tag($assets, $options = array()) { $default = array('type' => 'text/javascript'); return assets_include_tag($assets, '<script src="%s"%s></script>', array_merge($default, $options)); } function stylesheet_link_tag($assets, $options = array()) { $default = array('rel' => 'stylesheet', 'type' => 'text/css'); return assets_include_tag($assets, '<link href="%s"%s />', array_merge($default, $options)); } // Examples of usage: -
Tiago Dias revised this gist
Oct 18, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,4 +30,8 @@ function stylesheet_link_tag($assets) return assets_include_tag($assets, '<link rel="stylesheet" href="%s" type="text/css" />'); } // Examples of usage: // <?php echo stylesheet_link_tag(array('stylesheets/all.css')) ?> // <?php echo javascript_include_tag(array('javascripts/all.js')) ?> ?> -
Tiago Dias created this gist
Oct 18, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <?php define('_ROOT', dirname(realpath(__FILE__))); function assets_include_tag($assets, $tmpl) { if (empty($assets)) { return false; } $allAssets = ''; foreach ($assets as $asset) { $filepath = _ROOT . "/{$asset}"; if (is_file($filepath)) { $allAssets.= sprintf($tmpl, "{$asset}?v=" . filemtime($filepath)) . PHP_EOL; } } return $allAssets; } function javascript_include_tag($assets) { return assets_include_tag($assets, '<script src="%s"></script>'); } function stylesheet_link_tag($assets) { return assets_include_tag($assets, '<link rel="stylesheet" href="%s" type="text/css" />'); } ?>