Skip to content

Instantly share code, notes, and snippets.

@johndwells
Created April 17, 2015 09:55
Show Gist options
  • Save johndwells/e1eefceea68ee0d3405a to your computer and use it in GitHub Desktop.
Save johndwells/e1eefceea68ee0d3405a to your computer and use it in GitHub Desktop.
Example of how to configure Minimee for Craft on a per-tag basis.
{#
To start with, all Minimee tags by default run off the settings
from the database (via it's plugin settings page), OR
from craft/config/minimee.php if you prefer to configure it via the filesystem.
Then you can override individual settings, on a per-tag basis,
by passing a hash (Twig's name for a key => value array). You can either
set this hash first and then pass it, or pass it at the time of the minimee tag call.
#}
{#
Example 1:
Let's inline our webfont definitions so that the browser can start downloading them immediately.
Remember that Firefox and IE require fonts to be served from this domain.
The first parameter of the Minimee tag is a simple index array listing any file(s) to be processed.
The second parameter is the optional hash of settings. Only settings that you
wish to override from the defaults need to be included.
In our hash, we first specify that rather than returning an HTML tag linking to our compressed stylesheet,
we want to return the contents of that compressed file.
Then we want to take those contents and wrap them in our own HTML style tags, so we specify the return template.
#}
{{ craft.minimee.css([
'/assets/css/fonts.css'
],
{
returnType : 'contents',
cssReturnTemplate : '<style type="text/css">%s</style>'
}) }}
{#
Example 2:
Default usage this time, we just pass minimee a bunch of files to process.
Minimee runs off default config.
#}
{{ craft.minimee.css([
'/assets/css/vendor/normalize.css',
'/assets/vendor_pkg/owlcarousel/owl.carousel.css',
'/assets/vendor_pkg/fresco/fresco.css',
'/assets/vendor_pkg/fancybox/jquery.fancybox.css',
'/assets/vendor_pkg/tipped/css/tipped/tipped.css',
'/assets/css/application.css'
]) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment