added config taglib
authorSven Arnold <sven@schnuppe.(none)>
Mon, 13 Apr 2009 17:15:28 +0000 (19:15 +0200)
committerSven Arnold <sven@schnuppe.(none)>
Mon, 13 Apr 2009 17:15:28 +0000 (19:15 +0200)
grails-app/taglib/ConfigurationTagLib.groovy [new file with mode: 0644]

diff --git a/grails-app/taglib/ConfigurationTagLib.groovy b/grails-app/taglib/ConfigurationTagLib.groovy
new file mode 100644 (file)
index 0000000..996f011
--- /dev/null
@@ -0,0 +1,18 @@
+import org.codehaus.groovy.grails.commons.ConfigurationHolder
+
+class ConfigurationTagLib {
+       
+       static namespace = 'conf'
+       
+       def value = { attrs ->
+               def key = attrs['key']
+               def keys = []
+               key.split(/\./).each { keys.add(it) }
+               
+               def prop = ConfigurationHolder.config
+               while (keys.size > 0) {
+                       prop = prop.getProperty(keys.remove(0))
+               }
+               out << prop
+       }
+}