Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created June 17, 2014 15:24
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 jonathantneal/fab2310afe9d0c48e368 to your computer and use it in GitHub Desktop.
Save jonathantneal/fab2310afe9d0c48e368 to your computer and use it in GitHub Desktop.
Import CSS to cache
#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