1

我有一个用 Jekyll 构建的网站,用于对我正在处理的 JavaScript 项目进行快速原型设计:Choropleth

现在我决定将mustache.js引入项目,显然我遇到了流动布局 {{}} 语法与 mustache 语法冲突的问题。

有谁知道我可以简单地使用 mustache 的Set Delimiter功能来更改 mustache 在我的项目中的工作方式?如何将写入语法放入由 Jekyll/Liquid 生成的 JS 中?

4

2 回答 2

2

过去(一年多前)我发现它有问题,但我记得必须在我的实际模板中包含分隔符设置。例如:

{{=[[ ]]=}}

<div>There have been <strong>[[numVisits]]</strong> visits to this site!</div>

[[={{ }}=]]

虽然我不确定是否{{会正确解释初始值,因为其他一些库正在查看相同的模板。

于 2013-02-03T02:12:44.983 回答
2

在我放入 _posts 文件夹(默认 jekyll 设置)的页面中,我有以下内容:

---
layout:      test
categories:  tests
comments:    false
date:        2013-02-02 21:15:30
title:       Version 0.1.1 - geoJSON From Google Docs
subtitle:    Grab the Data from Google Docs Spreadsheet

mustacheSetDelimiter: "{{={u{ }u}=}}"
---

然后在下面我有以下测试线:

// Testing mustache template: use this to set new delimiter tags {{page.mustacheSetDelimiter}}
console.log(Mustache.render("{{page.mustacheSetDelimiter}} County name: {u{countyname}u}", masterGeoJSON.features[0].properties));

它就像一个魅力。

于 2013-02-03T02:29:45.443 回答