Clearsilver模板系统 - cs_render()和CSOUTFUNC的问题

时间:2011-06-15 19:03:52

标签: c template-engine clearsilver

从我的代码中摘录:

NEOERR*
func(void *,char *);
...
char* buf;
buf = (char*) malloc(1024);
HDF* hdf;
CSPARSE* cs;
hdf_init(&hdf);
hdf_set_value(hdf, "name", "foo"); 
cs_init(&cs, hdf);
strcpy(buf, "This is <?cs var:name ?>");
cs_parse_string(cs, buf, 1024);
cs_render(cs, NULL , func);
...
NEOERR*
func(void *b, char* a)
{
    printf("%s", a);
}

输出是:

This is<space>

如果我使用

strcpy(buf, "<?cs var:name ?>");

然后输出

foo

如何将模板命令与静态文本结合使用?我的CSOUTFUNC功能出了什么问题?

非常感谢提前

1 个答案:

答案 0 :(得分:0)

问题是缺少

return (STATUS_OK);

中的函数

NEOERR*
func(void *,char *);

解决。