From 832ad6653c28056ebe52e80d9a033d30b4e40a25 Mon Sep 17 00:00:00 2001 From: Ben Wiseley Date: Tue, 6 Mar 2012 15:13:43 +1100 Subject: [PATCH] Adding to README how to use JST for rendering templates --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index ed96add..d5b8dfa 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,28 @@ which contains your view state and any helper methods you want to call. Eco is fully synchronous. If your template needs to access data from asynchronous operations, perform those first before calling `render`. +## Usage with JST + +Another way to use eco with coffee scripts (for example, as the template engine for backbone.js). You can do this using JST. + +test.js.coffee + + options = [ { 'name': 'keyword', 'long': "Keywords and phrases" }, + { 'name': 'phone_number', 'long': "Phone number" } ] + rendered_template = JST['templates/test'](options) + alert(rendered_template) + +add this to application.js.coffee + + #= require_tree ./templates + +app/javascripts/templates/test.jst.eco: + +

Test

+ <% for option in this: %> +

Name <%= option['name']%> : Long <%= opition['long'] %>

+ <% end %> + ## Language reference Eco's syntax is simple: