|
mustache-c
1.0
|
Go to the source code of this file.
Data Structures | |
| struct | mustache_token_variable_t |
| struct | mustache_token_section_t |
| struct | mustache_token_t |
| struct | mustache_api_t |
| struct | mustache_str_ctx |
Typedefs | |
| typedef struct mustache_api_t | mustache_api_t |
| Api typedef. | |
| typedef struct mustache_token_t | mustache_token_t |
| Token typedef. | |
| typedef struct mustache_token_t | mustache_template_t |
| Template typedef. | |
| typedef enum mustache_token_type_t | mustache_token_type_t |
| Token type typedef. | |
|
typedef struct mustache_token_variable_t | mustache_token_variable_t |
| Token variable typedef. | |
|
typedef struct mustache_token_section_t | mustache_token_section_t |
| Token section typedef. | |
| typedef uintmax_t(* | mustache_api_read )(mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
| typedef uintmax_t(* | mustache_api_write )(mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
| typedef uintmax_t(* | mustache_api_varget )(mustache_api_t *api, void *userdata, mustache_token_variable_t *token) |
| typedef uintmax_t(* | mustache_api_sectget )(mustache_api_t *api, void *userdata, mustache_token_section_t *token) |
| typedef void(* | mustache_api_error )(mustache_api_t *api, void *userdata, uintmax_t lineno, char *error) |
| typedef void(* | mustache_api_freedata )(mustache_api_t *api, void *userdata) |
| typedef struct mustache_str_ctx | mustache_str_ctx |
Enumerations | |
| enum | mustache_token_type_t { TOKEN_TEXT, TOKEN_VARIABLE, TOKEN_SECTION } |
Functions | |
| mustache_template_t * | mustache_compile (mustache_api_t *api, void *userdata) |
| uintmax_t | mustache_prerender (mustache_api_t *api, void *userdata, mustache_template_t *template) |
| uintmax_t | mustache_render (mustache_api_t *api, void *userdata, mustache_template_t *template) |
| void | mustache_free (mustache_api_t *api, mustache_template_t *template) |
| uintmax_t | mustache_std_strread (mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
| Helper api function to read from plain C string. | |
| uintmax_t | mustache_std_strwrite (mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
| Helper api function to write to plain C string. | |
| void | mustache_dump (mustache_template_t *template) |
| Debug dump template. | |
| typedef void(* mustache_api_error)(mustache_api_t *api, void *userdata, uintmax_t lineno, char *error) |
Errors callback. Used only on compilation stage.
| api | Current api set |
| userdata | Userdata passed to mustache_compile function |
| lineno | Line number on which error occured |
| error | Error description |
| typedef void(* mustache_api_freedata)(mustache_api_t *api, void *userdata) |
Free userdata callback.
| api | Current api set |
| userdata | Userdata saved in tokens |
| typedef uintmax_t(* mustache_api_read)(mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
Read callback, used only on compilation stage. Write your data in buffer and return number of bytes read.
| api | Current api set, probably not used in this callback |
| userdata | Userdata passed to mustache_compile function |
| buffer | Output buffer |
| buffer_size | Output buffer size |
| 0 | No more data (EOF) |
| >0 | Successful call, number indicate number of bytes read |
| typedef uintmax_t(* mustache_api_sectget)(mustache_api_t *api, void *userdata, mustache_token_section_t *token) |
Get section callback. User call iterativly render routines on section, or do nothing.
| api | Current api set |
| userdata | Userdata passed to mustache_render function |
| token | Mustache section token |
| 0 | Error occured |
| >0 | Successful call |
| typedef uintmax_t(* mustache_api_varget)(mustache_api_t *api, void *userdata, mustache_token_variable_t *token) |
Get variable callback. User call ->write api to dump variable value to output, or do nothing.
| api | Current api set |
| userdata | Userdata passed to mustache_render function |
| token | Mustache variable token |
| 0 | Error occured |
| >0 | Successful call |
| typedef uintmax_t(* mustache_api_write)(mustache_api_t *api, void *userdata, char *buffer, uintmax_t buffer_size) |
Write callback. Save input data in desired place.
| api | Current api set |
| userdata | Userdata passed to mustache_render function |
| buffer | Input buffer |
| buffer_size | Input buffer size |
| 0 | Error occured |
| >0 | Successful call |
| typedef struct mustache_str_ctx mustache_str_ctx |
Helper context
| mustache_template_t* mustache_compile | ( | mustache_api_t * | api, |
| void * | userdata | ||
| ) |
Compile template
| api | Current api set |
| userdata | Userdata passed to ->read function |
| NULL | Error occured |
| !NULL | Successful call |
| void mustache_free | ( | mustache_api_t * | api, |
| mustache_template_t * | template | ||
| ) |
Free template
| template | Template to free |
| uintmax_t mustache_prerender | ( | mustache_api_t * | api, |
| void * | userdata, | ||
| mustache_template_t * | template | ||
| ) |
Prerender template. You will receive ->varget and ->sectget callbacks only, precompute some info if needed and save to userdata field.
| api | Current api set |
| userdata | Userdata passed to ->read function |
| template | Template to use for rendering |
| 0 | Error occured |
| >0 | Successful call |
| uintmax_t mustache_render | ( | mustache_api_t * | api, |
| void * | userdata, | ||
| mustache_template_t * | template | ||
| ) |
Render template
| api | Current api set |
| userdata | Userdata passed to ->write and other functions |
| template | Template to use for rendering |
| 0 | Error occured |
| >0 | Successful call |
1.7.5.1