github.com/coveo/gotemplate@v2.7.7+incompatible/docs/doc_test/!extensions.gte (about)

     1  GoTemplate Extension can contains plain text at the root level.
     2  
     3  Template to define algorithm to draw a fir.
     4  @define("draw_fir")
     5    @{colors := printf("Fg%s,Bg%s", fg, bg)}
     6    @{len := size * 2 * lenc(char) + len(color($colors))}
     7    @{r := to(1, size*2, 2)}
     8    @-if (reverse) @{r = $r[-1:0]};
     9    @-foreach ($n := $r)
    10      @center($len, color($colors, char * $n))
    11    @-end foreach
    12  @-end define
    13  
    14  Default configuration for regular fir.
    15  @{firConfig} := data(`
    16    default {
    17      size    = 15
    18      bg      = "Green"
    19      fg      = "White"
    20      char    = " "
    21      reverse = false
    22    }
    23    arguments   = ["size int" , "bg string", "fg string", "char string", "reverse bool"]
    24    description = "Draw a plain regular fir."
    25    group       = "Funny demo functions"
    26    aliases     = ["fir"]
    27  `)
    28  
    29  Default configuration for christmas tree.
    30  @{ctConfig} := data(`
    31    default { size = 20 fg = "Red" char = "✾" }
    32    description = "Draw a christmas tree."
    33    aliases     = ["ct"]
    34  `).Merge($firConfig)
    35  
    36  Register the functions.
    37  @func("Fir", "template", "draw_fir", $firConfig)
    38  @func("ChristmasTree", "template", "draw_fir", $ctConfig)