aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-11-07 19:30:34 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2018-11-07 19:30:34 -0500
commit03d363a337eea7fce725efbd51f99449e06395ef (patch)
tree7498ad5f60000cff87f7ebfeb85388919d20ef1d /src
parent72a26505d7c5f80d2f010c41969f6ec1f2a3a9a1 (diff)
downloadlibctemplates-03d363a337eea7fce725efbd51f99449e06395ef.tar.gz
libctemplates-03d363a337eea7fce725efbd51f99449e06395ef.tar.bz2
libctemplates-03d363a337eea7fce725efbd51f99449e06395ef.zip
Added a method to get errors from the template
Added a method const char* TMPL_err(TMPL_templates* t, size_t* size); t is the template that had an error size is a pointer, size of the error message is returned;
Diffstat (limited to 'src')
-rw-r--r--src/ctemplates.c5
-rw-r--r--src/ctemplates.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/src/ctemplates.c b/src/ctemplates.c
index 1de9b64..b8d9931 100644
--- a/src/ctemplates.c
+++ b/src/ctemplates.c
@@ -1159,6 +1159,11 @@ TMPL_render(struct TMPL_templates* t, struct TMPL_varlist* varlist, size_t* size
return ret;
}
+const char*
+TMPL_err(struct TMPL_templates* t, size_t* size){
+ return bstringify(t->errout,size);
+}
+
struct TMPL_templates*
TMPL_alloc_template(const char* tmplstr){
struct TMPL_templates* n = compile(tmplstr);
diff --git a/src/ctemplates.h b/src/ctemplates.h
index 4d4fac5..1df0f43 100644
--- a/src/ctemplates.h
+++ b/src/ctemplates.h
@@ -197,6 +197,7 @@ struct TMPL_loop* TMPL_alloc_loop(void);
void TMPL_free_loop(struct TMPL_loop* tl);
char* TMPL_render(struct TMPL_templates* t, struct TMPL_varlist* varlist, size_t* size_p);
+const char* TMPL_err(struct TMPL_templates* t, size_t* size);
struct TMPL_tagnode* TMPL_alloc_tagnode(enum TMPL_tagtype);
void TMPL_free_tagnode(struct TMPL_tagnode* tn);