ExtractContents returns the template contents without the YAML front-matter
(filePath string)
| 115 | |
| 116 | // ExtractContents returns the template contents without the YAML front-matter |
| 117 | func 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 | |
| 128 | var yamlPattern = regexp.MustCompile(`(?m)^---\r?\n(\s*\r?\n)?`) |
| 129 |