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

Jquery.tmpl.js can't render variables #5

Closed
loicginoux opened this issue Jul 4, 2011 · 1 comment
Closed

Jquery.tmpl.js can't render variables #5

loicginoux opened this issue Jul 4, 2011 · 1 comment

Comments

@loicginoux
Copy link

Hello,
I am learning spine and node.js (both look really promising) and found this spine.app you had made.
So to start, I generated the application structure with spine.app and incorporated your spine.todo application in the project.
everything was fine except jQuery templating which couldn't render any variable:

  • coffee script in Task.coffee:
        ##this.item being {name:'test',done:false}
        elements = $("#taskTemplate").tmpl this.item 

  • template in index.html:
<script type="text/x-jquery-tmpl" id="taskTemplate">
    <div class="item {{if done}}done{{/if}}">
      <div class="view" title="Double click to edit...">
        <input type="checkbox" {{if done}}checked="checked"{{/if}}> 
        <span>${name}</span> <a class="destroy"></a>
      </div>
    </div>
  </script>

the result was:

<script type="text/x-jquery-tmpl" id="taskTemplate">
    <div class="item">
      <div class="view" title="Double click to edit...">
        <input type="checkbox" {{if done}}checked="checked"{{/if}}> 
        <span>undefined</span> <a class="destroy"></a>
      </div>
    </div>
  </script>

by comparing Jquery.tmpl.js from your spine.app project and the one from your spine.todos project I could spot a difference at the line 341:

.replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )

was replaced in the spine.app by:

.replace( /\$\{([^\}]*)\}/g, "undefined" )

I replaced the file by the one in your spine.todos project and worked fine. It must have interpreted it in some way.
I just wanted to let you know about this issue.
keep it up, you are doing an awesome work.
Cheers

@maccman
Copy link
Member

maccman commented Jul 4, 2011

Yes, jQuery.tmpl made a weird decision (imho) and now doesn't execute ${} in the context of the data item. Either use the old one or ${$data.name} for the time being. I'm really hoping somebody will write a 'fixed' templating library someday.

@maccman maccman closed this as completed Jul 4, 2011
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