<commit_before>package stick_test

import (
	"os"

	"fmt"

	"github.com/tyler-sommer/stick"
)

// ExampleEnv_Execute shows a simple example of executing a template.
func ExampleEnv_Execute() {
	env := stick.NewEnv(nil)

	params := map[string]stick.Value{"name": "World"}
	env.Execute(`Hello, {{ name }}!`, os.Stdout, params)
	// Output: Hello, World!
}

type exampleType struct{}

func (e exampleType) Boolean() bool {
	return true
}

func (e exampleType) Number() float64 {
	return 3.14
}

func (e exampleType) String() string {
	return "some kinda string"
}

// ExampleBoolean demonstrates how a type can be coerced to a boolean.
// The struct in this example has the Boolean method implemented.
//
// 	func (e exampleType) Boolean() bool {
//    	return true
//    }
func ExampleBoolean() {
	v := exampleType{}
	fmt.Printf("%t", stick.CoerceBool(v))
	// Output: true
}

// ExampleCoerceBool demonstrates how various values are coerced to boolean.
func ExampleCoerceBool() {
	v0 := ""
	v1 := "some string"
	v2 := 0
	v3 := 3.14
	fmt.Printf("%t %t %t %t", stick.CoerceBool(v0), stick.CoerceBool(v1), stick.CoerceBool(v2), stick.CoerceBool(v3))
	// Output: false true false true
}

// ExampleCoerceNumber demonstrates how a type can be coerced to a number.
// The struct in this example has the Number method implemented.
//
// 	func (e exampleType) Number() float64 {
//    	return 3.14
//    }
func ExampleNumber() {
	v := exampleType{}
	fmt.Printf("%.2f", stick.CoerceNumber(v))
	// Output: 3.14
}

// ExampleCoerceNumber demonstrates how various values are coerced to number.
func ExampleCoerceNumber() {
	v0 := true
	v1 := ""
	v2 := "54"
	v3 := "1.33"
	fmt.Printf("%.f %.f %.f %.2f", stick.CoerceNumber(v0), stick.CoerceNumber(v1), stick.CoerceNumber(v2), stick.CoerceNumber(v3))
	// Output: 1 0 54 1.33
}

// ExampleCoerceString demonstrates how a type can be coerced to a string.
// The struct in this example has the String method implemented.
//
// 	func (e exampleType) String() string {
//    	return "some kinda string"
//    }
func ExampleStringer() {
	v := exampleType{}
	fmt.Printf("%s", v)
	// Output: some kinda string
}

// ExampleCoerceString demonstrates how various values are coerced to string.
func ExampleCoerceString() {
	v0 := true
	v1 := false // Coerces into ""
	v2 := 54
	v3 := 1.33
	v4 := 0
	fmt.Printf("%s '%s' %s %s %s", stick.CoerceString(v0), stick.CoerceString(v1), stick.CoerceString(v2), stick.CoerceString(v3), stick.CoerceString(v4))
	// Output: 1 '' 54 1.33 0
}<commit_msg>Formatting fix.<commit_after>package stick_test

import (
	"os"

	"fmt"

	"github.com/tyler-sommer/stick"
)

// ExampleEnv_Execute shows a simple example of executing a template.
func ExampleEnv_Execute() {
	env := stick.NewEnv(nil)

	params := map[string]stick.Value{"name": "World"}
	env.Execute(`Hello, {{ name }}!`, os.Stdout, params)
	// Output: Hello, World!
}

type exampleType struct{}

func (e exampleType) Boolean() bool {
	return true
}

func (e exampleType) Number() float64 {
	return 3.14
}

func (e exampleType) String() string {
	return "some kinda string"
}

// ExampleBoolean demonstrates how a type can be coerced to a boolean.
// The struct in this example has the Boolean method implemented.
//
//	func (e exampleType) Boolean() bool {
//		return true
//	}
func ExampleBoolean() {
	v := exampleType{}
	fmt.Printf("%t", stick.CoerceBool(v))
	// Output: true
}

// ExampleCoerceBool demonstrates how various values are coerced to boolean.
func ExampleCoerceBool() {
	v0 := ""
	v1 := "some string"
	v2 := 0
	v3 := 3.14
	fmt.Printf("%t %t %t %t", stick.CoerceBool(v0), stick.CoerceBool(v1), stick.CoerceBool(v2), stick.CoerceBool(v3))
	// Output: false true false true
}

// ExampleCoerceNumber demonstrates how a type can be coerced to a number.
// The struct in this example has the Number method implemented.
//
// 	func (e exampleType) Number() float64 {
//		return 3.14
//	}
func ExampleNumber() {
	v := exampleType{}
	fmt.Printf("%.2f", stick.CoerceNumber(v))
	// Output: 3.14
}

// ExampleCoerceNumber demonstrates how various values are coerced to number.
func ExampleCoerceNumber() {
	v0 := true
	v1 := ""
	v2 := "54"
	v3 := "1.33"
	fmt.Printf("%.f %.f %.f %.2f", stick.CoerceNumber(v0), stick.CoerceNumber(v1), stick.CoerceNumber(v2), stick.CoerceNumber(v3))
	// Output: 1 0 54 1.33
}

// ExampleCoerceString demonstrates how a type can be coerced to a string.
// The struct in this example has the String method implemented.
//
//	func (e exampleType) String() string {
//		return "some kinda string"
//	}
func ExampleStringer() {
	v := exampleType{}
	fmt.Printf("%s", v)
	// Output: some kinda string
}

// ExampleCoerceString demonstrates how various values are coerced to string.
func ExampleCoerceString() {
	v0 := true
	v1 := false // Coerces into ""
	v2 := 54
	v3 := 1.33
	v4 := 0
	fmt.Printf("%s '%s' %s %s %s", stick.CoerceString(v0), stick.CoerceString(v1), stick.CoerceString(v2), stick.CoerceString(v3), stick.CoerceString(v4))
	// Output: 1 '' 54 1.33 0
}
{'fraction_non_alphanumeric': 0.14762285257690771, 'fraction_numerical': 0.02796644027167399, 'mean_word_length': 3.728045325779037, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3573136', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1741, 'n_words': 537}