MCPcopy Index your code
hub / github.com/php/frankenphp / getTemplateContent

Method getTemplateContent

internal/extgen/cfile.go:58–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58func (cg *cFileGenerator) getTemplateContent() (string, error) {
59 funcMap := sprig.FuncMap()
60 funcMap["namespacedClassName"] = NamespacedName
61 funcMap["cString"] = escapeCString
62
63 tmpl := template.Must(template.New("cfile").Funcs(funcMap).Parse(cFileContent))
64
65 var buf bytes.Buffer
66 if err := tmpl.Execute(&buf, cTemplateData{
67 BaseName: cg.generator.BaseName,
68 Functions: cg.generator.Functions,
69 Classes: cg.generator.Classes,
70 Constants: cg.generator.Constants,
71 Namespace: cg.generator.Namespace,
72 }); err != nil {
73 return "", err
74 }
75
76 return buf.String(), nil
77}
78
79// escapeCString escapes characters that would break a C double-quoted string literal.
80func escapeCString(s string) string {

Calls 2

ParseMethod · 0.80
StringMethod · 0.45