Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindImports ¶
func FindImports(funcs []FunctionToCall, modulePath string) []string
Determines all imports needed to call provided functions.
func FindModulePath ¶
Finds path of the Go module the program is executed in.
Types ¶
type FunctionToCall ¶
type FunctionToCall struct { FileName string // preserve the templ filename for the generated html one PackageName string FunctionName string FilePath string // used to determine import needed IsAlone bool // whether the component is the only one declared in a file }
func FindFunctionsInFiles ¶
func FindFunctionsInFiles(files filePaths) ([]FunctionToCall, error)
Goes through the file paths provided and finds all exported fucntrions that take 0 parameters. Files provided must be valid Go source files.
func (*FunctionToCall) DirPath ¶
func (f *FunctionToCall) DirPath() string
Returns path to the directory in which the function can be found.
func (*FunctionToCall) HtmlFileName ¶
func (f *FunctionToCall) HtmlFileName() string
Returns a string to be used as the name for HTML file generated from this component.
Based on the original file name if component is the only one declared in the given file. Otherwise the function name is used.
The filename is slugified, e.g. "HelloWorld" -> "hello-world.html"
type GroupedFiles ¶ added in v1.1.0
type GroupedFiles struct { TemplGoFiles filePaths // "_templ.go" files TemplFiles filePaths // ".templ" files GoFiles filePaths // ".go" files, excluding "_templ.go" OtherFiles filePaths // other files }
func FindFilesInDir ¶
func FindFilesInDir(root string) (*GroupedFiles, error)
Finds paths to all files in the given directory and all its subdirecotries.
Groups the files into groupedFiles type, includes TemplGoFiles ("_templ.go"), TemplFiles (".templ"), GoFiles (other ".go" files) and OtherFiles.