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 //jb > On 11 Sep 2017, at 09:25, ivo.hechm...@gmail.com wrote: > > Hello golang-nuts, > > My problem: in a html page, I iterate over a list (of strings). the items are > names of backupfiles. Sometimes, a backup has failed, in this case, the > backupfilename contains the token .FAILED. > when i print the list of items, I would like to check if I have to print a > restore-link or not. Obviously, I should not print a restore link for backups > that contains the token .FAILED. > > <table width="100%" class="backups" border="0"> > {{ range $element := .Items }} > <tr> > <td>{{ $element }}</td> > {{ if CONDITION }} > <td><a > href="javascript:action('restore','{{$element}}');">Restore</a></td> > {{ end }} > </tr> > {{ end }} > </table> > > So i need a regex or -contains- function for CONDITION. But I only found the > eq, ne, lt, le, gt, and ge, functions. Is there a way to check a String in > the condition? > > Thank you very much for any hints... > > Ivo > > -- > 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. -- 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.