Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h2>Contribution Overview</h2> <p>GFreeMarker is <table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=INLINE" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUlOTElORX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>an integration of the FreeMarker template engine for Groovy</p></td></tr></table>. It allows adding plugins written in Groovy for content rendering, making FreeMarker+Groovy just as easy as <a href="http://smarty.php.net">Smarty</a>. This way of doing avoids security issues related to allowing direct Groovy scripting in templates. With GFreeMarker, <strong>you</strong> create plugins, and make it available to customers. <br class="atl-forced-newline" /> <br class="atl-forced-newline" /></p> <h3>Team Members</h3> <p>Cedric Champeau <cedric dot champeau at lingway dot com></p> <h2>Download</h2> <h3>Distributions</h3> <p><a class="confluence-link unresolved" data-filename="gfreemarker-0.2.0.jar" data-linked-resource-default-alias="gfreemarker-0.2.0.jar" href="#">GFreeMarker 0.2</a></p> <p><a class="confluence-link unresolved" data-filename="gfreemarker-0.2.0-javadoc.jar" data-linked-resource-default-alias="gfreemarker-0.2.0-javadoc.jar" href="#">GFreeMarker 0.2 (javadoc)</a></p> <p><a class="confluence-link unresolved" data-filename="gfreemarker-0.2.0-sources.jar" data-linked-resource-default-alias="gfreemarker-0.2.0-sources.jar" href="#">GFreeMarker 0.2 (sources)</a></p> <h3>Installing</h3> <p>Pending.</p> <h3>Pre-requisites</h3> <p>None.</p> <h2>Documentation</h2> <h3>How does it work ?</h3> <p>Imagine your customer requires an URL Encoding text transform, and that FreeMarker does not offer this transformation. Then, you would just need to :</p> <ul> <li>Create a plugin named urlencoder that implements the IGroovyFreeMarkerPlugin interface</li> <li>Copy this plugin into the Groovy FreeMarker template engine plugins directory</li> </ul> <p>That's all ! Now your customer can access it quite directly in the template. For example :</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="lang=xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZz14bWx9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <@groovy plugin="urlencoder">this is an expression that will be converted to its URL Encoding form</@groovy> </pre></td></tr></table> <h3>Writing a plugin</h3> <p>Here's a sample plugin which converts a string through URL encoder :</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.gfreemarker.IGroovyFreeMarkerPlugin class urlencoder implements IGroovyFreeMarkerPlugin { String transform(Map params, String content) { URLEncoder.encode(content); } } </pre></td></tr></table> <h3>Using the template engine</h3> <p>Here's a sample code which shows how easy it is to embed FreeMarker as a template engine for Groovy.</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.gfreemarker.FreeMarkerTemplateEngine def tpl = ''' Hello, ${user.name} <@groovy plugin="urlencoder" mode=user>this is a test ${user.name}</@groovy>''' def engine = new FreeMarkerTemplateEngine("plugins") def binding = ["user" : ["name":"cedric"]] println engine.createTemplate(tpl).make(binding) </pre></td></tr></table> <p>This code assumes a directory called <em>plugins</em> is in the working directory. The template engine will dynamically load the ''urlencoder'' class.</p> <h2>Developers</h2> <h3>Source Control</h3> <p><a href="http://svn.codehaus.org/groovy-contrib/gfreemarker/trunk/">http://svn.codehaus.org/groovy-contrib/gfreemarker/trunk/</a></p> <h3>Building</h3> <p>GFreeMarker uses Maven2 as its build tool. Follow the instructions at <a href="http://maven.apache.org">http://maven.apache.org</a> or install an IDE which has Maven 2 support (I personally use <a href="http://www.jetbrains.com">IntelliJ IDEA 7</a>).</p> <h3>Contributing</h3> <p>Feel free to contribute, as I don't have much time to spend on this project.</p> <h2>Community</h2> <h3>Mailing List(s)</h3> <p><a href="http://groovy.codehaus.org/Mailing+Lists">http://groovy.codehaus.org/Mailing+Lists</a></p> <h3>Issue tracker</h3> <p>N/A</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced