Sammy小胡子

编程入门 行业动态 更新时间:2024-10-22 23:40:38
Sammy小胡子 - 不工作(双括号中的变量未被值替换)(Sammy mustache - not working (variables in double braces not replaced with values))

我正在尝试使用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!

更多推荐

本文发布于:2023-07-29 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小胡子   Sammy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!