baryshev / ect

Fastest JavaScript template engine with embedded CoffeeScript syntax
http://ectjs.com
MIT License
626 stars 69 forks source link

Nested helpers #82

Closed emiliobool closed 10 years ago

emiliobool commented 10 years ago

is it possible to use nested helpers?

consider this case using @upperHelper inside linkHelper

{
    title : 'Hello, world!',
    id : 'main',
    links: [
        { name : 'Google', url : 'http://google.com/' },
        { name : 'Facebook', url : 'http://facebook.com/' },
        { name : 'Twitter', url : 'http://twitter.com/' }
    ],
    upperHelper : function (string) {
        return string.toUpperCase();
    }
}
<% linkHelper = (link) -> %>
    <li><a href="<%- link.url %>"><%- @upperHelper link.name %></a></li>
<% end %>

<% if @links?.length : %>
    <ul>
        <% for link in @links : %>
            <%- linkHelper link %>
        <% end %>
    </ul>
<% else : %>
    <p>List is empty</p>
<% end %>

not working for me, is there any workaround?

emiliobool commented 10 years ago

this is actually the same issue as https://github.com/baryshev/ect/issues/36 and that solution works fine