rules/recording.go
func (rule *RecordingRule) HTMLSnippet(pathPrefix string) template.HTML {
	ruleExpr := rule.vector.String()
	labels := make(map[string]string, len(rule.labels))
	for _, l := range rule.labels {
		labels[l.Name] = template.HTMLEscapeString(l.Value)
	}

	r := rulefmt.Rule{
		Record: fmt.Sprintf(`<a href="%s">%s</a>`, pathPrefix+strutil.TableLinkForExpression(rule.name), rule.name),
		Expr:   fmt.Sprintf(`<a href="%s">%s</a>`, pathPrefix+strutil.TableLinkForExpression(ruleExpr), template.HTMLEscapeString(ruleExpr)),
		Labels: labels,
	}

	byt, err := yaml.Marshal(r)
	if err != nil {
		return template.HTML(fmt.Sprintf("error marshaling recording rule: %q", template.HTMLEscapeString(err.Error())))
	}

	return template.HTML(byt)
}
func (rule *RecordingRule) HTMLSnippet(pathPrefix string) template.HTML {
	ruleExpr := rule.vector.String()
	labels := make(map[string]string, len(rule.labels))
	for _, l := range rule.labels {
		labels[l.Name] = template.HTMLEscapeString(l.Value)
	}

	r := rulefmt.Rule{
		Record: fmt.Sprintf(`<a href="%s">%s</a>`, pathPrefix+strutil.TableLinkForExpression(rule.name), rule.name),
		Expr:   fmt.Sprintf(`<a href="%s">%s</a>`, pathPrefix+strutil.TableLinkForExpression(ruleExpr), template.HTMLEscapeString(ruleExpr)),
		Labels: labels,
	}

	byt, err := yaml.Marshal(r)
	if err != nil {
		return template.HTML(fmt.Sprintf("error marshaling recording rule: %q", template.HTMLEscapeString(err.Error())))
	}

	return template.HTML(byt)
}
func ( rule * RecordingRule ) HTMLSnippet ( pathPrefix string ) template . HTML { ruleExpr := rule . vector . String ( ) labels := make ( map [ string ] string , len ( rule . labels ) ) for _ , l := range rule . labels { labels [ l . Name ] = template . HTMLEscapeString ( l . Value ) } r := rulefmt . Rule { Record : fmt . Sprintf ( `<a href="%s">%s</a>` , pathPrefix + strutil . TableLinkForExpression ( rule . name ) , rule . name ) , Expr : fmt . Sprintf ( `<a href="%s">%s</a>` , pathPrefix + strutil . TableLinkForExpression ( ruleExpr ) , template . HTMLEscapeString ( ruleExpr ) ) , Labels : labels , } byt , err := yaml . Marshal ( r ) if err != nil { return template . HTML ( fmt . Sprintf ( " " , template . HTMLEscapeString ( err . Error ( ) ) ) ) } return template . HTML ( byt ) }
// HTMLSnippet returns an HTML snippet representing this rule.
HTMLSnippet returns an HTML snippet representing this rule .