Created
June 16, 2011 21:48
-
-
Save rahulsom/1030375 to your computer and use it in GitHub Desktop.
Grails TagLib for Blueprint
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
/** | |
* 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