diff --git a/grammar.go b/grammar.go index 218cf74..36cde9a 100644 --- a/grammar.go +++ b/grammar.go @@ -938,7 +938,9 @@ func TemplateFuncs() template.FuncMap { "plural": Pluralize, "pluralForm": PluralForm, "article": ArticlePhrase, + "articlePhrase": ArticlePhrase, "definite": DefinitePhrase, + "definitePhrase": DefinitePhrase, "quote": Quote, "label": Label, "progress": Progress, diff --git a/grammar_test.go b/grammar_test.go index 3d503f4..ef5d506 100644 --- a/grammar_test.go +++ b/grammar_test.go @@ -1110,6 +1110,9 @@ func TestTemplateFuncs(t *testing.T) { "plural", "pluralForm", "article", + "articlePhrase", + "definite", + "definitePhrase", "quote", "label", "progress", @@ -1142,6 +1145,20 @@ func TestTemplateFuncs_Article(t *testing.T) { if got, want := buf.String(), "an apple"; got != want { t.Fatalf("template article = %q, want %q", got, want) } + + tmpl, err = template.New("").Funcs(TemplateFuncs()).Parse(`{{articlePhrase "apple"}}|{{definitePhrase "apple"}}`) + if err != nil { + t.Fatalf("Parse() alias helpers failed: %v", err) + } + + buf.Reset() + if err := tmpl.Execute(&buf, nil); err != nil { + t.Fatalf("Execute() alias helpers failed: %v", err) + } + + if got, want := buf.String(), "an apple|the apple"; got != want { + t.Fatalf("template article aliases = %q, want %q", got, want) + } } func TestTemplateFuncs_CompositeHelpers(t *testing.T) {