template

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT

README

template

GitHub tag Go Report Card Code coverage

Made with Golang Using Diagrams

BuyMeACoffee

Overview

The TemplateGenerator provides functionality to generate files using Go's text/template and apply formatting based on file extensions. It encapsulates the generation process and allows customization through options.

Features

  • Parse text templates.
  • Execute templates with provided data.
  • Generate files based on templates.
  • Apply formatting based on file extensions. Supported formaters:
    • .go -> Go
    • .tf -> Terraform

How to Use

$ go get github.com/diagram-code-generator/template@latest

Example Usage

ackage main

import (
	"github.com/diagram-code-generator/template/pkg/generators"
)

func main() {
	// Create a new TemplateGenerator instance
	tg := generators.NewTemplateGenerator()

	// Define data to be used in the template
	data := struct {
		Name string
	}{
		Name: "Joselito",
	}

	// Define a text template
	templateContent := "Hello, {{.Name}}!"

	// Build and execute the template
	output, err := tg.Build(data, "example_template", templateContent)
	if err != nil {
		panic(err)
	}

	// Print the output
	fmt.Println(output)
}

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to create an issue or submit a pull request. Your contribution is much appreciated. See Contributing.

open - Contributing

License

This project is licensed under the MIT License.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL