Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Added doc on using JST #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<h1>Test</h1>
<% for option in this: %>
<p>Name <%= option['name']%> : Long <%= opition['long'] %></p>
<% end %>

## Language reference

Eco's syntax is simple:
Expand Down