Created
July 26, 2013 15:27
-
-
Save danveloper/6089781 to your computer and use it in GitHub Desktop.
Grails Countdown Timer TagLib
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
class CountdownTagLib { | |
static namespace = "ct" | |
def down = { args -> | |
out << """ | |
<span id='conf-countdown'></span> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-countdown/1.6.1/jquery.countdown.min.js"></script> | |
<script> | |
(function() { | |
\$("#conf-countdown").countdown({ until: new Date($args.year, ${Integer.parseInt(args.month)-1}, $args.day) }); | |
})(); | |
</script> | |
""" | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<ct:down month="12" year="2013" day="25" /> | |
</body> | |
</html> |
I made a few changes to integrate with Resources: https://github.com/pledbrook/talk-submissions/blob/master/grails-app/taglib/cacoethes/UtilTagLib.groovy#L5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You know tags are supposed to verify their args, right? ;) Seriously though, thanks for this. Will add to talk submission app when I get the chance (AKA when I feel like it).