我正在尝试使用sammy和mustache模板来编写我的第一个webapp。 模板似乎无法正确呈现(双括号中的变量不会替换为值)。 这是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 boiler myapp”生成基本结构
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"
最满意答案
傻我,我忘了包括“sammy.mustache.js”。 我以为做了这个.use('Mustache')会自动加载它!
Silly me, I'd forgotten to include "sammy.mustache.js". I thought doing a this.use('Mustache') would automatically load it!
更多推荐
发布评论