github.com/Liam-Williams/i18n4go@v0.2.7-0.20201028180611-670cbaceaa6b/test_fixtures/rewrite_package/f_option/expected_output/test_templated_strings.go (about)

     1  package input_files
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  func Templated() string {
     9  	name := T("cruel")
    10  	myName := T("evil")
    11  	fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": name}))
    12  	fmt.Println(T("Hello {{.Name}} world!, bye from {{.MyName}}", map[string]interface{}{"Name": name, "MyName": myName}))
    13  	fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": T("Evil")}))
    14  
    15  	//These should not have a map[string]interface{}
    16  	fmt.Println(T("Hello {{Not complex}} world! I am"), name)
    17  	fmt.Println(T("Hello {{}}"), myName)
    18  
    19  	fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)}))
    20  	fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(T("Hi"))}))
    21  	fmt.Println(T("Hello {{.Name}} world! {{.Number}} times", map[string]interface{}{"Name": name, "Number": 10}))
    22  	fmt.Println(T("Hello {{.Name}} world! {{.Float}} times", map[string]interface{}{"Name": name, "Float": 10.0}))
    23  
    24  	fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)}))}))
    25  
    26  	type something struct {
    27  	}
    28  
    29  	foo := something{}
    30  	strz := []string{T("one"), T("two"), T("buckle my shoe")}
    31  	fmt.Println(T("Welp, that's a great {{.MyStruct}} how about a {{.Whatever}}", map[string]interface{}{"MyStruct": &foo, "Whatever": strz[2]}))
    32  
    33  	println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": name}))
    34  	println(T("Hello {{.Name}} world! {{.Name}}", map[string]interface{}{"Name": name}))
    35  }