Commit 2cec0f1f authored by josé bollo's avatar josé bollo

Revise the escape character to be : (colon)

Also adds test cases and fix a bug when name started with = Change-Id: Ie13cf43f61ae45107bdbd429ec2bb5ab1f87f55c Signed-off-by: josé bollo's avatarJosé Bollo <jobol@nonadev.net>
parent 13e00a6c
mustach: mustach-tool.c mustach.c mustach.h mustach-json-c.c mustach-json-c.h
$(CC) -o mustach mustach-tool.c mustach.c mustach-json-c.c -ljson-c
$(CC) -g -o mustach mustach-tool.c mustach.c mustach-json-c.c -ljson-c
.PHONY: test clean
......
......@@ -83,6 +83,8 @@ static struct json_object *find(struct expl *e, const char *name)
n = strdupa(name);
v = keyval(n);
c = key(&n);
if (c == NULL)
return NULL;
o = NULL;
i = e->depth;
while (i >= 0 && !json_object_object_get_ex(e->stack[i].obj, c, &o))
......
......@@ -104,7 +104,7 @@ static int process(const char *template, struct mustach_itf *itf, void *closure,
case '/':
case '&':
case '>':
case '\\':
case ':':
beg++; len--;
default:
while (len && isspace(beg[0])) { beg++; len--; }
......
......@@ -11,5 +11,12 @@
],
"person?": { "name": "Jon" },
"special": "----{{extra}}----",
"extra": 3.14159
"extra": 3.14159,
"#sharp": "#",
"!bang": "!",
"/slash": "/",
"^circ": "^",
"=equal": "=",
":colon": ":",
">greater": ">"
}
......@@ -28,3 +28,11 @@ ggggggggg
{{> special}}
jjjjjjjjj
end
{{:#sharp}}
{{:!bang}}
{{:/slash}}
{{:^circ}}
{{:\=equal}}
{{::colon}}
{{:>greater}}
......@@ -30,3 +30,11 @@ ggggggggg
----3.14159----
jjjjjjjjj
end
#
!
/
^
=
:
&gt;
......@@ -6,7 +6,7 @@ Command: ../mustach json must
HEAP SUMMARY:
in use at exit: 0 bytes in 0 blocks
total heap usage: 159 allocs, 159 frees, 27,936 bytes allocated
total heap usage: 189 allocs, 189 frees, 29,869 bytes allocated
All heap blocks were freed -- no leaks are possible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment