1

我正在使用 mustache(在 ruby​​ 中)从哈希生成 XML 文档。

有没有办法从 XML 文档和 mustache 模板生成哈希?

4

1 回答 1

0

想了一会儿,我意识到这是不可能的。有多个使用 Mustache 创建同一个文档的原始哈希实例,因此这永远不会合理可行。

其中包括:

doc = {
  "words": [
    "an",
    "aconda"
  ]
}

template = "here's some words: {{#words}}{{.}}{{/words}}"

out = Mustache.render(template,doc)
# => "here's some words: anaconda"

Mustache.reverse(template,out)
# {'words' => ['anaconda']}
于 2013-02-01T10:37:54.810 回答