Documentation ¶
Index ¶
- Variables
- func ToCamelCase(s string) string
- func ToKebabCase(s string) string
- func ToPascalCase(s string) string
- func ToSnakeCase(s string) string
- type DefaultGitClient
- type DepInfo
- type Executor
- func (e *Executor) EmbedFunc(remotePath string, data interface{}) (string, error)
- func (e *Executor) ImportFunc(outputDir string) func(repoAndTag, destPath string, data interface{}) (string, error)
- func (e *Executor) ParsePath(inputPath string) error
- func (e Executor) Render(name string, data interface{}) (string, error)
- func (e Executor) StringRender(templateString string, data interface{}) (string, error)
- func (e *Executor) WalkAndProcessDir(inputDir, outputDir string, data interface{}) error
- type GitClient
Constants ¶
This section is empty.
Variables ¶
var DefaultFuncMap = template.FuncMap{ "lower": strings.ToLower, "upper": strings.ToUpper, "trim": strings.TrimSpace, "split": strings.Split, "join": strings.Join, "replace": strings.ReplaceAll, "contains": strings.Contains, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, "trimPrefix": strings.TrimPrefix, "trimSuffix": strings.TrimSuffix, "trimSpace": strings.TrimSpace, "trimLeft": strings.TrimLeft, "trimRight": strings.TrimRight, "count": strings.Count, "repeat": strings.Repeat, "equalFold": strings.EqualFold, "splitN": strings.SplitN, "splitAfter": strings.SplitAfter, "splitAfterN": strings.SplitAfterN, "fields": strings.Fields, "toTitle": strings.ToTitle, "toSnakeCase": ToSnakeCase, "toCamelCase": ToCamelCase, "toKebabCase": ToKebabCase, "toPascalCase": ToPascalCase, "default": defaultVal, }
DefaultFuncMap is the default function map for templates.
Functions ¶
func ToPascalCase ¶
ToPascalCase converts a string to PascalCase.
Types ¶
type DefaultGitClient ¶
type DefaultGitClient struct { Token string // contains filtered or unexported fields }
DefaultGitClient provides a default implementation for the GitClient interface.
func NewDefaultGitClient ¶
func NewDefaultGitClient(defaultBranch string, token string) *DefaultGitClient
NewDefaultGitClient creates a new DefaultGitClient with the given token.
func (*DefaultGitClient) Checkout ¶
func (d *DefaultGitClient) Checkout(path, ref string) error
Checkout checks out a branch, tag or commit hash in a Git repository.
func (*DefaultGitClient) Clone ¶
func (d *DefaultGitClient) Clone(host, owner, repo, dest string) error
Clone clones a Git repository to the given destination.
func (*DefaultGitClient) DefaultBranch ¶
func (d *DefaultGitClient) DefaultBranch() string
DefaultBranch returns the default branch name.
type DepInfo ¶
DepInfo contains information about an embed URL.
func ParseDepURL ¶
ParseDepURL is a parsed embed URL.
type Executor ¶
Executor is a wrapper around the template.Template type
func (*Executor) EmbedFunc ¶
EmbedFunc returns a template function that can be used to process and embed a template from a remote git repository. EmbedFunc allows embedding content from a remote repository directly into a Go template.
Steps to use:
- Add the function to the FuncMap.
- Use the following syntax within your template: ``` {{ embed "<host>/<owner>/<repo>/<path>@<tag_or_hash_or_branch>" . }} {{ embed "<host>/<owner>/<repo>#<block>@<tag_or_hash_or_branch>" . }} ```
Placeholders:
- `<host>`: Repository hosting service (e.g., "github.com").
- `<owner>`: Repository owner or organization.
- `<repo>`: Repository name.
- `<path>`: Path to the desired file or directory within the repository.
- `<block>`: Specific template block name.
- `<tag_or_hash_or_branch>`: Specific Git reference (tag, commit hash, or branch name).
func (*Executor) ImportFunc ¶
func (e *Executor) ImportFunc(outputDir string) func(repoAndTag, destPath string, data interface{}) (string, error)
ImportFunc returns a function that can be used as a template function to import and process a template from a remote git repository. ImportFunc allows embedding content from a remote repository into a Go template.
Steps to use:
- Add the function to the FuncMap.
- Use the following syntax within your template: ``` {{ import "<host>/<owner>/<repo>/<path>@<tag_or_hash_or_branch>" "<path_to_genrate_files>" . }} {{ import "<host>/<owner>/<repo>/<path>#<block>@<tag_or_hash_or_branch>" "<path_to_genrate_files>" . }} ```
Placeholders:
- `<host>`: Repository hosting service (e.g., "github.com").
- `<owner>`: Repository owner or organization.
- `<repo>`: Repository name.
- `<path>`: Path to the desired file or directory within the repository.
- `<tag_or_hash_or_branch>`: Specific Git reference (tag, commit hash, or branch name).
func (Executor) StringRender ¶
StringRender renders the given template string with the given data
func (*Executor) WalkAndProcessDir ¶
WalkAndProcessDir processes all files in a directory with the given data. If walkFunc is provided, it's called for each file and directory without writing the file to disk.