Created
June 17, 2014 15:24
-
-
Save jonathantneal/fab2310afe9d0c48e368 to your computer and use it in GitHub Desktop.
Import CSS to cache
This file contains 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
#set($css_cache = {}) | |
#macro (importCSS $path) | |
## if the path does not yet exist as a key in the cache | |
#if (!$css_cache.containsKey($path)) | |
## load the path contents | |
#set($css = $_.locateFile($path)) | |
## if the file exists, cache the contents using the path as the key | |
#if ($css) | |
$css_cache.put($path, $css.text) | |
#end | |
#end | |
#end | |
## load a sample file into the cache | |
#importCSS("files/css/grassy.css") | |
## get the contents of a cached file | |
$css_cache.get("files/css/grassy.css") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment