【问题标题】:Sammy mustache - not working (variables in double braces not replaced with values)Sammy mustache - 不工作(双括号中的变量未替换为值)
【发布时间】:2012-10-16 07:33:35
【问题描述】:

我正在尝试使用 sammy 和 mustache 模板编写我的第一个 web 应用程序。模板似乎无法正确呈现(双括号中的变量不会被值替换)。这是 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>

以及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();
});

这是我的简单模板 (hello.ms)--

Hello {{name}}.

当我点击 Hello 链接时,它呈现为

你好{{name}}。

我的期望是:

你好拉姆。

任何提示我在这里做错了什么? 谢谢。

PS。基本结构是使用“couchapp锅炉myapp”生成的

【问题讨论】:

    标签: jquery mustache couchapp sammy.js


    【解决方案1】:

    我真傻,我忘了包括“sammy.mustache.js”。我认为执行 this.use('Mustache') 会自动加载它!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-24
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      相关资源
      最近更新 更多