MCPcopy
hub / github.com/cli/cli / ExtractContents

Function ExtractContents

pkg/githubtemplate/github_template.go:117–126  ·  view source on GitHub ↗

ExtractContents returns the template contents without the YAML front-matter

(filePath string)

Source from the content-addressed store, hash-verified

115
116// ExtractContents returns the template contents without the YAML front-matter
117func ExtractContents(filePath string) []byte {
118 contents, err := os.ReadFile(filePath)
119 if err != nil {
120 return []byte{}
121 }
122 if frontmatterBoundaries := detectFrontmatter(contents); frontmatterBoundaries[0] == 0 {
123 return contents[frontmatterBoundaries[1]:]
124 }
125 return contents
126}
127
128var yamlPattern = regexp.MustCompile(`(?m)^---\r?\n(\s*\r?\n)?`)
129

Callers 2

BodyMethod · 0.92
TestExtractContentsFunction · 0.85

Calls 1

detectFrontmatterFunction · 0.85

Tested by 1

TestExtractContentsFunction · 0.68