Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A grails plugin. To be used with the grails-resources plugin, it allows for eco templates to be defined as a resource just like css, or javascript.
Groovy
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.settings
grails-app
scripts
src/groovy/com/saasplex/eco
test/integration/com/saasplex/eco
web-app/WEB-INF
.classpath
.gitignore
.project
EcoResourcesGrailsPlugin.groovy
README.md
application.properties
plugin.xml

README.md

This is a Grails plugin than enables the easy inclusion of eco templates into a Grails appplication. It requires the well established resources plugin.

Background

Eco is yet another Javascript templating tool. Eco is written by PrototypeJs author Sam Stephenson.

It uses Mozilla's Rhino engine to execute the original eco compiler written in javascript.

Usage

To add eco template files to your grails project:

  • Install the plugin (adding to your BuildConfig is best)
  • Actually add the eco tempalte files to your project. I placed mine adjacent to the js folder in eco.
  • Reference your eco files in your ApplicationResources file (or where ever your defining your resources)

Example

  eco {
    resource url: 'eco/dir.eco'
    resource url: 'eco/entry.eco'
    resource url: 'eco/category.eco'
  }  

The above example will create a resource you can include in pages or have another resource depend on. The templates are converted into javascript objects in the Global name space. The naming of these js objects follows the pattern "eco.$fileName" where the filename does not include the extension.

Example eco tempate people.eco

  <ul>
    <% for person in @people: %>
      <li> <%= person.name %></li>      
    <% end %>
  </ul>

which could be referenced in your javascript code like this:

  $("li").html( eco.people( { people: [{ name: 'John' }, { name: 'Mary'}] } ) );
Something went wrong with that request. Please try again.