--- a/gplate/gplate-template.c Wed Feb 27 23:19:32 2008 -0600
+++ b/gplate/gplate-template.c Sun Mar 02 00:57:58 2008 -0600
@@ -49,6 +49,11 @@
+} GPlateTemplateTagData; /******************************************************************************
*****************************************************************************/
@@ -130,16 +135,11 @@
-} GPlateTemplateFindTagData;
gplate_template_find_tag_helper(GType tag, const gchar *prefix,
const gchar *suffix, gpointer d)
- GPlateTemplateFindTagData *data = (GPlateTemplateFindTagData *)d;
+ GPlateTemplateTagData *data = (GPlateTemplateTagData *)d; /* if our tag info doesn't have a prefix or a suffix, we drop out. */
@@ -163,8 +163,8 @@
-gplate_template_find_tag(GPlateTemplate *tplate, const gchar *contents) {
- GPlateTemplateFindTagData d;
+gplate_template_find_tag(GPlateTemplate *tplate, gchar *contents) { + GPlateTemplateTagData d; @@ -640,6 +640,80 @@
+gplate_template_render_until(GPlateTemplate *tplate, ...) { + gchar *contents = NULL; + g_return_val_if_fail(GPLATE_IS_TEMPLATE(tplate), NULL); + str = g_string_new(""); + /* store all of the content/tag pairs */ + va_start(args, tplate); + while((contents = va_arg(args, gchar *)) != NULL) { + GPlateTemplateTagData *td = NULL; + td = g_new(GPlateTemplateTagData, 1); + td->contents = contents; + td->type = va_arg(args, GType); + g_queue_push_tail(queue, td); + /* now iterate the tags */ + while((tag = gplate_template_next_tag(tplate))) { + GPlateTemplateTagData ctd; + ctd.contents = gplate_tag_get_contents(tag); + ctd.type = G_OBJECT_TYPE(tag); + /* run through our list of TagData's to stop on */ + for(l = queue->head; l; l = l->next) { + GPlateTemplateTagData *td = (GPlateTemplateTagData *)l->data; + if(ctd.type == td->type && + g_utf8_collate(ctd.contents, td->contents) == 0) + g_string_append_printf(str, "%s", + gplate_template_render_tag(tplate, tag)); + /* now clean everything up... */ + for(l = queue->head; l; l = l->next) { + GPlateTemplateTagData *td = (GPlateTemplateTagData *)l->data; + g_string_free(str, FALSE); * gplate_template_first_tag:
* @tplate: The #GPlateTemplate.
--- a/gplate/gplate-template.h Wed Feb 27 23:19:32 2008 -0600
+++ b/gplate/gplate-template.h Sun Mar 02 00:57:58 2008 -0600
@@ -76,6 +76,8 @@
gchar *gplate_template_render(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
gchar *gplate_template_render_file(GPlateTemplate *tplate, const gchar *filename, GError **error);
+gchar *gplate_template_render_until(GPlateTemplate *tplate, ...); GPlateTag *gplate_template_first_tag(GPlateTemplate *tplate);
GPlateTag *gplate_template_last_tag(GPlateTemplate *tplate);
GPlateTag *gplate_template_current_tag(GPlateTemplate *tplate);