[gnome-builder/gnome-builder-3-20] template: give templates access to {{author}} and {{year}}



commit 58772716f7adf220ff4ffa676ee41b3a4d0bac80
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 14 13:24:27 2016 +0300

    template: give templates access to {{author}} and {{year}}
    
    These are common too, and should just be part of template base.

 libide/template/ide-template-base.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/libide/template/ide-template-base.c b/libide/template/ide-template-base.c
index e0b03dd..e645374 100644
--- a/libide/template/ide-template-base.c
+++ b/libide/template/ide-template-base.c
@@ -628,6 +628,8 @@ ide_template_base_add_resource (IdeTemplateBase *self,
   TmplSymbol *symbol;
   g_autofree gchar *uri = NULL;
   g_autofree gchar *filename = NULL;
+  g_autofree gchar *year = NULL;
+  g_autoptr(GDateTime) now = NULL;
 
   g_return_if_fail (IDE_IS_TEMPLATE_BASE (self));
   g_return_if_fail (resource_path != NULL);
@@ -654,6 +656,14 @@ ide_template_base_add_resource (IdeTemplateBase *self,
   filename = g_file_get_basename (destination);
   tmpl_symbol_assign_string (symbol, filename);
 
+  symbol = tmpl_scope_get (expansion.scope, "author");
+  tmpl_symbol_assign_string (symbol, g_get_real_name ());
+
+  now = g_date_time_new_now_local ();
+  year = g_date_time_format (now, "%Y");
+  symbol = tmpl_scope_get (expansion.scope, "year");
+  tmpl_symbol_assign_string (symbol, year);
+
   g_array_append_val (priv->files, expansion);
 }
 


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