--- a/gplate/gplate-template.c Sun Feb 17 03:28:20 2008 -0600
+++ b/gplate/gplate-template.c Sun Feb 17 05:46:51 2008 -0600
@@ -401,6 +401,81 @@
/******************************************************************************
+ *****************************************************************************/ +static inline GPlateFunction * +gplate_template_render_find_function(const gchar *name, GType tag, + gboolean *deffunc, GError **error) + GPlateFunction *ret = NULL; + GType function = G_TYPE_INVALID; + function = gplate_library_lookup_function_for_tag(name, tag, NULL); + if(function == G_TYPE_INVALID) { + function = gplate_library_get_default_function_for_tag(tag, NULL); + if(function != G_TYPE_INVALID) { + ret = g_object_new(function, NULL); +gplate_template_render_token(GPlateTemplate *tplate, const gchar *contents, + GType tag, GError **error) + GPlateFunction *function = NULL; + GMatchInfo *info = NULL; + gchar *name = NULL, *ret = NULL; + gboolean deffunc = FALSE; + regex = g_regex_new("(.*?)(\\s(.*?)?)", + G_REGEX_OPTIMIZE | G_REGEX_MULTILINE, 0, NULL); + if(!g_regex_match(regex, contents, 0, &info)) { + name = g_match_info_fetch(info, 1); + gplate_template_render_find_function(name, tag, &deffunc, error); + ret = gplate_function_evaluate(function, tplate, contents); + gchar *leftovers = g_match_info_fetch(info, 2); + ret = gplate_function_evaluate(function, tplate, leftovers); + g_object_unref(G_OBJECT(function)); + g_match_info_free(info); + return (ret) ? ret : g_strdup(""); +/****************************************************************************** *****************************************************************************/
@@ -510,12 +585,16 @@
for(l = tokens; l; l = l->next) {
GPlateTag *tag = GPLATE_TAG(l->data);
- gchar *contents = gplate_tag_render(tag, tplate);
+ GType ttype = G_OBJECT_TYPE(tag); + gchar *contents = NULL, *output = NULL;
- g_string_append_printf(str, "%s", contents);
+ contents = gplate_tag_get_contents(tag); + output = gplate_template_render_token(tplate, contents, ttype, error); + g_string_append_printf(str, "%s", output); --- a/gplate/gplate-template.h Sun Feb 17 03:28:20 2008 -0600
+++ b/gplate/gplate-template.h Sun Feb 17 05:46:51 2008 -0600
@@ -47,6 +47,7 @@
GList *(*tokenize)(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
+ gchar *(*render)(GPlateTemplate *tplate, const gchar *tplate_string, GError **error); GPlateTag *(*first_tag)(GPlateTemplate *tplate);
GPlateTag *(*last_tag)(GPlateTemplate *tplate);