Skip to content

Instantly share code, notes, and snippets.

@rahulsom
Created June 16, 2011 21:48
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 rahulsom/1030375 to your computer and use it in GitHub Desktop.
Save rahulsom/1030375 to your computer and use it in GitHub Desktop.
Grails TagLib for Blueprint
/**
* Creates blueprint taglib to use blueprint css in a nice and clean way
* For generating css, see https://gist.github.com/1023323
*/
class BlueprintTagLib {
static namespace = "blueprint"
/**
* Uses a blueprint stylesheet set
*/
def use = { attrs, body ->
def dir = attrs['dir']
def condition = attrs['condition']
def printRequired = attrs['print']
def ieRequired = attrs['ie']
def screen = g.resource(dir: "css/$dir", file: "screen.css")
def ie = g.resource(dir: "css/$dir", file: "ie.css")
def printSheet = g.resource(dir: "css/$dir", file: "print.css")
if (condition == null) {
out << """<link rel="stylesheet" href="$screen" media="screen"/>"""
} else {
out << """<link rel="stylesheet" href="$screen" media="only screen and $condition"/>"""
if (ieRequired != null && ieRequired == 'true') {
out << """ <!--[if IE]>\
<link rel="stylesheet" href="$screen" media="screen, projection"/>\
<![endif]-->"""
}
}
if (ieRequired != null && ieRequired == 'true') {
out << """<!--[if lt IE 8]>\
<link rel="stylesheet" href="$ie" media="screen, projection"/>\
<![endif]-->"""
}
if (printRequired != null && printRequired == 'true') {
out << """<link rel="stylesheet" href="$printSheet" media="print"/>"""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment