Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for directives #1

Closed
calvinte opened this issue May 2, 2013 · 1 comment
Closed

Support for directives #1

calvinte opened this issue May 2, 2013 · 1 comment

Comments

@calvinte
Copy link

calvinte commented May 2, 2013

I'd like to be able to add directives to expressions in a similar fashion to how modifiers are executed against values now. My particular use case (see code below) would be to support nested templates.

Template:

<strong>{{ list.name }}</strong>
<ul class="things">
  {% for thing in list.things|attachThings %}
    <li class="thing {{thing.class}}">
    </li>
  {% endfor %}
</ul>

Javascript:

var thingTemplate = 'Thing: {{thing.name}}';
var list = {
  name: 'Test List',
  things: [
    {name: 'testThing1', class: 'textThing1Class'},
    {name: 'testThing2', class: 'textThing2Class'}
  ]
}

Ashe.addDirectives({
  attachThings: function(values) {
    values.forEach(function(v) {
        // key `thing` equal to `thing` in loop.
        v.thing;
        // key `template` is `Array` containing elements inside loop,
        v.template;

        var element = $('.thing', template);
        var content = Ashe.parse(thingTemplate, thing);
        element.html(content);
    });
  }
  // , oneMoreDirective: function(values) { ... }
});

What are you thoughts on this being included in Ashe?

@dfsq
Copy link
Owner

dfsq commented May 12, 2013

This looks nice. However I'm a little tight on time in the moment. So not sure if I will support Ashe at all. There are better options like Handelbars I believe.

@dfsq dfsq closed this as completed Jun 16, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants