[gnome-builder] templates: give templates access to {{filename}} symbol



commit 2969aae86748277ad8a7e7e5e1b15d7c1494144a
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 14 13:19:17 2016 +0300

    templates: give templates access to {{filename}} symbol
    
    This just defines filename to the basename of the destination file.

 libide/template/ide-template-base.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/libide/template/ide-template-base.c b/libide/template/ide-template-base.c
index 86f1f5d..e0b03dd 100644
--- a/libide/template/ide-template-base.c
+++ b/libide/template/ide-template-base.c
@@ -625,7 +625,9 @@ ide_template_base_add_resource (IdeTemplateBase *self,
 {
   IdeTemplateBasePrivate *priv = ide_template_base_get_instance_private (self);
   FileExpansion expansion = { 0 };
+  TmplSymbol *symbol;
   g_autofree gchar *uri = NULL;
+  g_autofree gchar *filename = NULL;
 
   g_return_if_fail (IDE_IS_TEMPLATE_BASE (self));
   g_return_if_fail (resource_path != NULL);
@@ -648,6 +650,10 @@ ide_template_base_add_resource (IdeTemplateBase *self,
   expansion.result = NULL;
   expansion.mode = mode;
 
+  symbol = tmpl_scope_get (expansion.scope, "filename");
+  filename = g_file_get_basename (destination);
+  tmpl_symbol_assign_string (symbol, filename);
+
   g_array_append_val (priv->files, expansion);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]