Question

I'm trying to write my first webapp using sammy and mustache templating. The template doesn't seem to render correctly (variables in double braces are not replaced with values). Here's the relevent part of index.html --

  <script language="javascript" type="text/javascript" src="jquery-1.4.4.min.js"></script>
  <script language="javascript" type="text/javascript" src="sammy/sammy.js"></script>
  <script language="javascript" type="text/javascript" src="site.js"></script>

  <a href="#/hello">Hello</a>

  <div id="container">
  </div>

And the relevent part of site.js--

$(function () { 
  app.s = $.sammy("#container", function () {
    this.use('Mustache', 'ms');
    // Index of all databases
    this.get('', app.index);
    this.get("#/", app.index);
    this.get("#/hello", function(context) {
        context.name = "Ram";
        context.partial('hello.ms', {name:"Ram"});
    });
  })
  app.s.run();
});

And this is my simple template (hello.ms)--

Hello {{name}}.

When I click on the Hello link, it is rendered as

Hello {{name}}.

what I expect is:

Hello Ram.

Any hints what I'm doing wrong here? Thanks.

PS. The basic structure is generated using "couchapp boiler myapp"

Was it helpful?

Solution

Silly me, I'd forgotten to include "sammy.mustache.js". I thought doing a this.use('Mustache') would automatically load it!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top