我正在尝试使用CL-MUSTACHE 。按照 README 中的示例,渲染原子变量工作正常。文件:
> (mustache:mustache-render-to-string "{{year}}-{{month}}-{{day}}"
'((:year . "2012")
(:month . "07")
(:day . "02")))
"2012-07-02"
但是,我无法弄清楚如何传递列表来多次渲染一个部分。 README文件没有示例,我尝试过的方法不起作用。例如:
(mustache:mustache-render-to-string "{{#dates}}{{year}}-{{month}}-{{day}}
{{/dates}}"
'((:dates . (((:year . "2012")
(:month . "07")
(:day . "02"))
((:year . "2013")
(:month . "08")
(:day . "03"))))))
"--
"
最佳答案
我没有它来检查,但从文档来看,数组似乎被视为 CL 数组,所以你可以尝试这个看看它是否有效:
(mustache:mustache-render-to-string "{{#dates}}{{year}}-{{month}}-{{day}}{{/dates}}"
'((:dates . #( ((:year . "2012")
(:month . "07")
(:day . "02"))
((:year . "2013")
(:month . "08")
(:day . "03"))))))
(即参数列表的数组)。
关于common-lisp - 如何将列表传递给 cl-mustache?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11301654/