Since, I have made 2 more float-to-int functions and they work fine.

To solve this I'm having to pre-marshal my json before I execute the 
template.

Please if anyone knows why it doesn't like JSON encoding functions in the 
templates, let me know


On Saturday, July 30, 2016 at 4:32:12 AM UTC+2, 
alex.b...@leadinglocally.com wrote:
>
> func encodeJSON(data interface{}) template.JS {
> a, err := json.Marshal(data)
> if err != nil { panic(err) }
>
> return template.JS(a)
> }
>
> // code for rendering ELEMENT
>
> func (ele *ELEMENT) Render() ([]byte, error) {
>
> // init map of functions available to use within delimiters
>
> if funcMap == nil {
> funcMap = template.FuncMap{
> "divideFF": divideFF,
> "percentageFF": percentageFF,
> "percentageIF": percentageIF,
> "encodeJSON": encodeJSON,
> }
> }
>
> when executing only the encodeJSON function I get this: template: x:19: 
> function "encodeJSON" not defined
>
> all others work fine, and I checked the correct code is in my gopath.
>
> please advise... I had the encodeJSON func returning a string before but 
> it didn't work either
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to