Exemple #1
0
func (tmpl PongoTemplate) Content() []string {
	pa, ok := tmpl.engine.loader.TemplatePaths[tmpl.Name()]
	if !ok {
		pa, ok = tmpl.engine.loader.TemplatePaths[strings.ToLower(tmpl.Name())]
	}
	content, _ := revel.ReadLines(pa)
	return content
}
Exemple #2
0
// Parse the output of the "go build" command.
// Return a detailed Error.
func newCompileError(output []byte) *revel.Error {
	errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`).
		FindSubmatch(output)
	if errorMatch == nil {
		errorMatch = regexp.MustCompile(`(?m)^(.*?)\:(\d+)\:\s(.*?)$`).FindSubmatch(output)

		if errorMatch == nil {
			revel.ERROR.Println("Failed to parse build errors:\n", string(output))
			return &revel.Error{
				SourceType:  "Go code",
				Title:       "Go Compilation Error",
				Description: "See console for build error.",
			}
		}

		errorMatch = append(errorMatch, errorMatch[3])

		revel.ERROR.Println("Build errors:\n", string(output))
	}

	// Read the source for the offending file.
	var (
		relFilename    = string(errorMatch[1]) // e.g. "src/revel/sample/app/controllers/app.go"
		absFilename, _ = filepath.Abs(relFilename)
		line, _        = strconv.Atoi(string(errorMatch[2]))
		description    = string(errorMatch[4])
		compileError   = &revel.Error{
			SourceType:  "Go code",
			Title:       "Go Compilation Error",
			Path:        relFilename,
			Description: description,
			Line:        line,
		}
	)

	errorLink := revel.Config.StringDefault("error.link", "")

	if errorLink != "" {
		compileError.SetLink(errorLink)
	}

	fileStr, err := revel.ReadLines(absFilename)
	if err != nil {
		compileError.MetaError = absFilename + ": " + err.Error()
		revel.ERROR.Println(compileError.MetaError)
		return compileError
	}

	compileError.SourceLines = fileStr
	return compileError
}
Exemple #3
0
func (haml HamlTemplate) Content() []string {
	content, _ := revel.ReadLines(haml.engine.loader.TemplatePaths[haml.Name()])
	return content
}