From 96e712e9b6998477882b3c490ca4b8077952b092 Mon Sep 17 00:00:00 2001 From: Adam Moss <2951486+adam-moss@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:47:03 +0000 Subject: [PATCH 1/2] test: add .j2 test data Signed-off-by: Adam Moss <2951486+adam-moss@users.noreply.github.com> --- main_test.go | 2 +- testdata/expected/file.j2 | 34 ++++++++++++++++++++++++++++++++++ testdata/initial/file.j2 | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 testdata/expected/file.j2 create mode 100644 testdata/initial/file.j2 diff --git a/main_test.go b/main_test.go index 5aa7648..a13da95 100644 --- a/main_test.go +++ b/main_test.go @@ -399,7 +399,7 @@ func TestLicenseHeader(t *testing.T) { }, { []string{ - ".j2", + "f.j2", }, "{#\nHYS\n#}\n\n", }, diff --git a/testdata/expected/file.j2 b/testdata/expected/file.j2 new file mode 100644 index 0000000..d33372d --- /dev/null +++ b/testdata/expected/file.j2 @@ -0,0 +1,34 @@ + +{# +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#} + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file diff --git a/testdata/initial/file.j2 b/testdata/initial/file.j2 new file mode 100644 index 0000000..e566be4 --- /dev/null +++ b/testdata/initial/file.j2 @@ -0,0 +1,18 @@ + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file From e5dc7704624d90b83ece6fe1f908b6f3135ef847 Mon Sep 17 00:00:00 2001 From: Adam Moss <2951486+adam-moss@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:48:59 +0000 Subject: [PATCH 2/2] refactor: support .jinja and .jinja alongside .j2 Signed-off-by: Adam Moss <2951486+adam-moss@users.noreply.github.com> --- main.go | 2 +- main_test.go | 2 +- testdata/expected/file.jinja | 34 ++++++++++++++++++++++++++++++++++ testdata/expected/file.jinja2 | 34 ++++++++++++++++++++++++++++++++++ testdata/initial/file.jinja | 18 ++++++++++++++++++ testdata/initial/file.jinja2 | 18 ++++++++++++++++++ 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 testdata/expected/file.jinja create mode 100644 testdata/expected/file.jinja2 create mode 100644 testdata/initial/file.jinja create mode 100644 testdata/initial/file.jinja2 diff --git a/main.go b/main.go index b7ad0b8..18bb5a4 100644 --- a/main.go +++ b/main.go @@ -359,7 +359,7 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by ".wxi", ".wxl", ".wxs", ".xml": lic, err = executeTemplate(tmpl, data, "") - case ".j2": + case ".j2", ".jinja2", ".jinja": lic, err = executeTemplate(tmpl, data, "{#", "", "#}") case ".ml", ".mli", ".mll", ".mly": lic, err = executeTemplate(tmpl, data, "(**", " ", "*)") diff --git a/main_test.go b/main_test.go index a13da95..5adb4ed 100644 --- a/main_test.go +++ b/main_test.go @@ -399,7 +399,7 @@ func TestLicenseHeader(t *testing.T) { }, { []string{ - "f.j2", + "f.j2", "f.jinja2", "f.jinja", }, "{#\nHYS\n#}\n\n", }, diff --git a/testdata/expected/file.jinja b/testdata/expected/file.jinja new file mode 100644 index 0000000..d33372d --- /dev/null +++ b/testdata/expected/file.jinja @@ -0,0 +1,34 @@ + +{# +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#} + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file diff --git a/testdata/expected/file.jinja2 b/testdata/expected/file.jinja2 new file mode 100644 index 0000000..d33372d --- /dev/null +++ b/testdata/expected/file.jinja2 @@ -0,0 +1,34 @@ + +{# +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#} + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file diff --git a/testdata/initial/file.jinja b/testdata/initial/file.jinja new file mode 100644 index 0000000..e566be4 --- /dev/null +++ b/testdata/initial/file.jinja @@ -0,0 +1,18 @@ + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file diff --git a/testdata/initial/file.jinja2 b/testdata/initial/file.jinja2 new file mode 100644 index 0000000..e566be4 --- /dev/null +++ b/testdata/initial/file.jinja2 @@ -0,0 +1,18 @@ + + + + My Webpage + + + + +

My Webpage

+ {{ a_variable }} + + {# a comment #} + + \ No newline at end of file