bou.ke/statictemplate@v0.0.0-20180821122055-510411a5e7dd/funcs/funcs.go (about)

     1  package funcs
     2  
     3  import (
     4  	"fmt"
     5  	"text/template"
     6  	_ "unsafe"
     7  )
     8  
     9  var Funcs = map[string]interface{}{
    10  	"and":   And,
    11  	"or":    Or,
    12  	"not":   Not,
    13  	"eq":    Eq,
    14  	"ne":    Ne,
    15  	"lt":    Lt,
    16  	"le":    Le,
    17  	"gt":    Gt,
    18  	"ge":    Ge,
    19  	"index": Index,
    20  	"len":   Length,
    21  	"call":  Call,
    22  
    23  	"html":     Html,
    24  	"js":       Js,
    25  	"urlquery": Urlquery,
    26  	"print":    Print,
    27  	"printf":   Printf,
    28  	"println":  Println,
    29  
    30  	"_html_template_attrescaper":     Attrescaper,
    31  	"_html_template_commentescaper":  Commentescaper,
    32  	"_html_template_cssescaper":      Cssescaper,
    33  	"_html_template_cssvaluefilter":  Cssvaluefilter,
    34  	"_html_template_htmlnamefilter":  Htmlnamefilter,
    35  	"_html_template_htmlescaper":     Htmlescaper,
    36  	"_html_template_jsregexpescaper": Jsregexpescaper,
    37  	"_html_template_jsstrescaper":    Jsstrescaper,
    38  	"_html_template_jsvalescaper":    Jsvalescaper,
    39  	"_html_template_nospaceescaper":  Htmlnospaceescaper,
    40  	"_html_template_rcdataescaper":   Rcdataescaper,
    41  	"_html_template_urlescaper":      Urlescaper,
    42  	"_html_template_urlfilter":       Urlfilter,
    43  	"_html_template_urlnormalizer":   Urlnormalizer,
    44  }
    45  
    46  //go:linkname and text/template.and
    47  func and(arg0 interface{}, args ...interface{}) interface{}
    48  func And(arg0 interface{}, args ...interface{}) interface{} {
    49  	return and(arg0, args...)
    50  }
    51  
    52  //go:linkname or text/template.or
    53  func or(arg0 interface{}, args ...interface{}) interface{}
    54  func Or(arg0 interface{}, args ...interface{}) interface{} {
    55  	return or(arg0, args...)
    56  }
    57  
    58  //go:linkname not text/template.not
    59  func not(arg interface{}) bool
    60  func Not(arg interface{}) bool {
    61  	return not(arg)
    62  }
    63  
    64  //go:linkname eq text/template.eq
    65  func eq(arg1 interface{}, arg2 ...interface{}) (bool, error)
    66  func Eq(arg1 interface{}, arg2 ...interface{}) (bool, error) {
    67  	return eq(arg1, arg2...)
    68  }
    69  
    70  //go:linkname ne text/template.ne
    71  func ne(arg1, arg2 interface{}) (bool, error)
    72  func Ne(arg1, arg2 interface{}) (bool, error) {
    73  	return ne(arg1, arg2)
    74  }
    75  
    76  //go:linkname lt text/template.lt
    77  func lt(arg1, arg2 interface{}) (bool, error)
    78  func Lt(arg1, arg2 interface{}) (bool, error) {
    79  	return lt(arg1, arg2)
    80  }
    81  
    82  //go:linkname le text/template.le
    83  func le(arg1, arg2 interface{}) (bool, error)
    84  func Le(arg1, arg2 interface{}) (bool, error) {
    85  	return le(arg1, arg2)
    86  }
    87  
    88  //go:linkname gt text/template.gt
    89  func gt(arg1, arg2 interface{}) (bool, error)
    90  func Gt(arg1, arg2 interface{}) (bool, error) {
    91  	return gt(arg1, arg2)
    92  }
    93  
    94  //go:linkname ge text/template.ge
    95  func ge(arg1, arg2 interface{}) (bool, error)
    96  func Ge(arg1, arg2 interface{}) (bool, error) {
    97  	return ge(arg1, arg2)
    98  }
    99  
   100  //go:linkname index text/template.index
   101  func index(item interface{}, indices ...interface{}) (interface{}, error)
   102  func Index(item interface{}, indices ...interface{}) (interface{}, error) {
   103  	return index(item, indices...)
   104  }
   105  
   106  //go:linkname length text/template.length
   107  func length(item interface{}) (int, error)
   108  func Length(item interface{}) (int, error) {
   109  	return length(item)
   110  }
   111  
   112  //go:linkname call text/template.call
   113  func call(fn interface{}, args ...interface{}) (interface{}, error)
   114  func Call(fn interface{}, args ...interface{}) (interface{}, error) {
   115  	return call(fn, args...)
   116  }
   117  
   118  func Html(args ...interface{}) string {
   119  	return template.HTMLEscaper(args...)
   120  }
   121  
   122  func Js(args ...interface{}) string {
   123  	return template.JSEscaper(args...)
   124  }
   125  
   126  func Urlquery(args ...interface{}) string {
   127  	return template.URLQueryEscaper(args...)
   128  }
   129  
   130  func Print(a ...interface{}) string {
   131  	return fmt.Sprint(a...)
   132  }
   133  
   134  func Printf(format string, a ...interface{}) string {
   135  	return fmt.Sprintf(format, a...)
   136  }
   137  
   138  func Println(a ...interface{}) string {
   139  	return fmt.Sprintln(a...)
   140  }