Skip to content

Commit

Permalink
Merge branch 'master' of github.com:halfbaked/grails-eco-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
halfbaked committed Jan 27, 2012
2 parents ee29704 + 07a5a82 commit 830c3e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 2 additions & 3 deletions EcoResourcesGrailsPlugin.groovy
@@ -1,4 +1,3 @@

import org.grails.plugin.resource.ResourceProcessor


Expand All @@ -25,7 +24,7 @@ See: https://github.com/sstephenson/eco
'''

// URL to the plugin's documentation
def documentation = "http://grails.org/plugin/eco-resources"
def documentation = "https://github.com/halfbaked/grails-eco-resources"

// Extra (optional) plugin metadata

Expand All @@ -42,7 +41,7 @@ See: https://github.com/sstephenson/eco
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]

// Online location of the plugin's browseable source code.
// def scm = [ url: "http://svn.grails-plugins.codehaus.org/browse/grails-plugins/" ]
def scm = [ url: "https://github.com/halfbaked/grails-eco-resources" ]

def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
Expand Down
27 changes: 18 additions & 9 deletions README.md
Expand Up @@ -11,26 +11,35 @@ It uses Mozilla's [Rhino engine](https://github.com/matthieu/rhymeno) to execute
## Usage

To add eco template files to your grails project:
* Install the plugin - I have yet to add it to the Plugin Portal

* Install the plugin ( I have yet to add it to the Plugin Portal )
* 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
<pre>
eco {
resource url: 'eco/dir.eco'
resource url: 'eco/entry.eco'
resource url: 'eco/category.eco'
}
</pre>

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 would be referenced in your javascript code as:
eco.people([person:{ name: 'John' }])

<pre>
&lt;ul&gt;
&lt;% for person in @people: %&gt;
&lt;li&gt; &lt;%= person.name %&gt;&lt;/li&gt;
&lt;% end %&gt;
&lt;/ul&gt;
</pre>

which could be referenced in your javascript code like this:
<pre>
$("li").html( eco.people( { people: [{ name: 'John' }, { name: 'Mary'}] } ) );
</pre>

0 comments on commit 830c3e8

Please sign in to comment.