From 53412fb07923ec83ee16a8b30cda56c3fd42b557 Mon Sep 17 00:00:00 2001 From: Jeevanandam M Date: Fri, 10 Feb 2017 13:41:06 -0800 Subject: [PATCH] convenient render data type --- render/render.go | 5 ++++- reply/reply.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/render/render.go b/render/render.go index 3b47c97b..73ef7104 100644 --- a/render/render.go +++ b/render/render.go @@ -19,6 +19,9 @@ import ( var appConfig *config.Config type ( + // Data type used for convenient data type of map[string]interface{} + Data map[string]interface{} + // Render interface Render interface { Render(io.Writer) error @@ -56,7 +59,7 @@ type ( HTML struct { Template *template.Template Layout string - ViewArgs map[string]interface{} + ViewArgs Data } ) diff --git a/reply/reply.go b/reply/reply.go index c0fb1faf..aa77950b 100644 --- a/reply/reply.go +++ b/reply/reply.go @@ -205,7 +205,7 @@ func (r *Reply) FileInline(filename string, file io.ReadCloser) *Reply { // template => /views/pages/app/login.html // => /views/pages/App/Login.html // -func (r *Reply) HTML(data map[string]interface{}) *Reply { +func (r *Reply) HTML(data render.Data) *Reply { r.Rdr = &render.HTML{ ViewArgs: data, } @@ -215,7 +215,7 @@ func (r *Reply) HTML(data map[string]interface{}) *Reply { // HTMLl method renders based on given layout and data. Refer `Reply.HTML(...)` // method. -func (r *Reply) HTMLl(layout string, data map[string]interface{}) *Reply { +func (r *Reply) HTMLl(layout string, data render.Data) *Reply { r.Rdr = &render.HTML{ Layout: layout, ViewArgs: data,