Abdiel Lopez

Results 74 comments of Abdiel Lopez

Hey, I am having a similar question. Would it be possible to pass the context to a funcMap? ```go router.SetFuncMap(template.FuncMap{ "isLoggedIn": isLoggedIn, "getUser": getUser, }) ``` And then use those...

I think it would be totally possible to optionally get access to the context from a function in the FuncMap

@jincheng9 yeah, I looked at that, and I guess I could've put more effort into trying to see if it would work. Just read https://github.com/gin-gonic/gin#using-middleware which shows this code ```go...

Basically, by simply allowing a `c *gin.Context` for the functions in FuncMap, it would provide a super elegant way of solving the above problem of having template wide "IsUserLoggedIn" (or...

> Is it possible to access the gin.Context object from a template function? Specifically, I would like to read the content of an HTTP header. I mean the original issue...

I feel like the FuncMap os pretty much useless without access to a gin.Context

> possible to pass the context to a funcMap? @barats No. I have just manually pasted IsLoggedIn into each call to c.HTML like this ```go c.HTML( http.StatusOK, "template.html", gin.H{ "IsLoggedIn":...

EDIT: looking/thinkig back on what I said, I am realizing that threads are already a common primitive, thus foring evertying to not be able to use them woudln;t make sense.

@fgmccabe I'd love to get involved, although I probably can't right now due to circumstances, but good luck!