gpt4 book ai didi

javascript - 模板中的 Mustache php 空间

转载 作者:行者123 更新时间:2023-11-27 23:06:34 24 4
gpt4 key购买 nike

我有这个模板代码:

{{#album}}
<h1>{{ hinfo.artist_name }}</h1>
<h2>{{ hinfo.name }}</h2>
{{/album}}

呈现:

<h1></h1><h2></h2>

如果我写:

{{#album}}
<h1>{{hinfo.artist_name}}</h1>
<h2>{{hinfo.name}}</h2>
{{/album}}

成功显示:

<h1>my artist</h1><h2>my album name</h2>

javascript version在同一个库中,这种带有空格的行为不会发生。我在 php 构造函数中添加了一个函数助手:

$mustache = new Mustache_Engine( 
array(
'loader' => new Mustache_Loader_FilesystemLoader(
self::$_dir,
array('extension' => '.mst')
),
/*
'helpers' => array(
'fn' => function($text, $render) {
$parsed = $render($text);
$date = date("F j, Y h:i", (int) $parsed);
return $date;
}
)*/
)
);

但在此示例中并未执行。

谁能告诉我这种行为是否正确或者是 mustache 中的错误2.10版本?

最佳答案

一切似乎都按预期进行。我不确定您的问题是什么。

确切

在 Mustache.php 中,{{hinfo.artist_name}}(无空格)是正确的语法。

在 Mustache.js 中,{{ hinfo.artist_name }}(带有空格)是正确的语法。

关于javascript - 模板中的 Mustache php 空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36533317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com