Thank you very much.
Indeed, it would be clean to use Objects instead of simple Strings to flag
if a dump can be restored or not.
I've added the function strings.Contains before parsing the template-files:
templates, err = template.New("").Funcs(template.FuncMap{
"Contains": strings.Contains}).ParseFiles(allFiles...)
And in the template I can parse the String now:
{{ if (Contains $element ".FAILED.") }}
{{ else }}
<a href="javascript:action('restore','{{$element}}',
false);">Restore</a>
{{ end }}
one day, I will change the Objects passed to the template :)
Thank you very much
Ivo
On Monday, September 11, 2017 at 2:56:38 PM UTC+2, Shawn Milochik wrote:
>
> On Mon, Sep 11, 2017 at 7:32 AM, Jakob Borg <[email protected]
> <javascript:>> wrote:
>
>> The clean way to do this, in my opinion, is to make your item/element a
>> type that knows whether it's failed or not.
>>
>> https://play.golang.org/p/K_t8iEZvUc
>>
>> You can also inject strings.Contains or similar using
>> https://golang.org/pkg/html/template/#Template.Funcs
>>
>>
> Or return the strings in two separate slices -- one for the "good" and the
> other for the failed. It would not only solve this problem, but allow you
> to separate the failed ones visually.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.