diff --git a/.gitmodules b/.gitmodules index f2c90a1cad..24b296fbbd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1386,6 +1386,9 @@ [submodule "vendor/grammars/vscode-go"] path = vendor/grammars/vscode-go url = https://github.com/golang/vscode-go +[submodule "vendor/grammars/vscode-go-template"] + path = vendor/grammars/vscode-go-template + url = https://github.com/jinliming2/vscode-go-template.git [submodule "vendor/grammars/vscode-hack"] path = vendor/grammars/vscode-hack url = https://github.com/slackhq/vscode-hack diff --git a/grammars.yml b/grammars.yml index 9da8a9b6a2..ee91a86fe1 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1230,6 +1230,12 @@ vendor/grammars/vscode-gleam: vendor/grammars/vscode-go: - go.mod - go.sum +vendor/grammars/vscode-go-template: +- source.go-template +- source.go.injection.double.go-template +- source.go.injection.raw.go-template +- text.injection.go-template +- text.markdown.go-template.codeblock vendor/grammars/vscode-hack: - markdown.hack.codeblock - source.hack diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index ddaacd9e6b..aabcb68df3 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -870,6 +870,12 @@ disambiguations: pattern: '^## |@no-lib-strip@' - language: TeX pattern: '^\\(contentsline|defcounter|beamer|boolfalse)' +- extensions: ['.tpl'] + rules: + - language: Go Template + pattern: '\{\{-?\s*(\`?\"\\?\"?|\/\*\s|\w*)\b' + - language: Smarty + pattern: '(?> +``` + +The command deploys the chart on the Kubernetes cluster in the default configuration. + +## Uninstalling the Chart + +To uninstall/delete the my-release deployment: + +```console +helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +{{ template "helm-docs.versionFooter" . }} + +{{- end }} diff --git a/samples/Go Template/base.tpl b/samples/Go Template/base.tpl new file mode 100644 index 0000000000..cd5af26f75 --- /dev/null +++ b/samples/Go Template/base.tpl @@ -0,0 +1,36 @@ +{{ /* Example from https://github.com/go-echarts/go-echarts/blob/master/templates/base.tpl */ }} +{{- define "base_element" -}} +
+
+
+{{- end -}} + +{{- define "base_script" -}} + +{{- end -}} + +{{- define "base_option" }} + {{- .JSONNotEscaped | safeJS }} +{{- end }}; + +{{- define "base" }} + {{- template "base_element" . }} + {{- template "base_script" . }} +{{- end }} diff --git a/samples/Go Template/batch.gohtml b/samples/Go Template/batch.gohtml new file mode 100644 index 0000000000..2a1a688886 --- /dev/null +++ b/samples/Go Template/batch.gohtml @@ -0,0 +1,57 @@ +{{- /* https://github.com/ncruces/RethinkRAW/blob/master/assets/batch.gohtml */ -}} + + + + + + RethinkRAW: Batch processing {{len .Photos}} photos + + + + + + + + + + + + + + + + + + {{- template "raw-editor.gohtml" "hidden"}} + + + + + + Lorem ipsum
+ +
+ + + diff --git a/samples/Go Template/crd.tmpl b/samples/Go Template/crd.tmpl new file mode 100644 index 0000000000..bd3252a308 --- /dev/null +++ b/samples/Go Template/crd.tmpl @@ -0,0 +1,110 @@ +{{- /* https://github.com/grafana/k6-operator/blob/main/docs/crd.tmpl */ -}} +--- +title: {{or .Metadata.Title "API Reference"}} +weight: {{or .Metadata.Weight 1 }} +{{- if .Metadata.Description}} +description: {{.Metadata.Description}} +{{- end}} +--- + + +Packages: +{{range .Groups}} +- [{{.Group}}/{{.Version}}](#{{ anchorize (printf "%s/%s" .Group .Version) }}) +{{- end -}}{{/* range .Groups */}} + +{{- range .Groups }} +{{- $group := . }} + +# {{.Group}}/{{.Version}} + +Resource Types: +{{range .Kinds}} +- [{{.Name}}](#{{ anchorize .Name }}) +{{end}}{{/* range .Kinds */}} + +{{range .Kinds}} +{{$kind := .}} +## {{.Name}} +[↩ Parent](#{{ anchorize (printf "%s/%s" $group.Group $group.Version) }} ) + +{{range .Types}} + +{{if not .IsTopLevel}} +### {{.Name}} +{{if .ParentKey}}[↩ Parent](#{{.ParentKey}}){{end}} +{{end}} + + +{{.Description}} + + + + + + + + + + + + {{- if .IsTopLevel -}} + + + + + + + + + + + + + + + + + + + {{- end -}} + {{- range .Fields -}} + + + + + + + {{- end -}} + +
NameTypeDescriptionRequired
apiVersionstring{{$group.Group}}/{{$group.Version}}true
kindstring{{$kind.Name}}true
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
{{if .TypeKey}}{{.Name}}{{else}}{{.Name}}{{end}}{{.Type}} + {{.Description}}
+ {{- if or .Schema.XValidations .Schema.Format .Schema.Enum .Schema.Default .Schema.Minimum .Schema.Maximum }} +
+ {{- end}} + {{- if .Schema.XValidations }} + Validations: + {{- range .Schema.XValidations -}} +
  • {{ .Rule }}: {{ .Message }}
  • + {{- end -}} + {{- end }} + {{- if .Schema.Format }} + Format: {{ .Schema.Format }}
    + {{- end }} + {{- if .Schema.Enum }} + Enum: {{ .Schema.Enum | toStrings | join ", " }}
    + {{- end }} + {{- if .Schema.Default }} + Default: {{ .Schema.Default }}
    + {{- end }} + {{- if .Schema.Minimum }} + Minimum: {{ .Schema.Minimum }}
    + {{- end }} + {{- if .Schema.Maximum }} + Maximum: {{ .Schema.Maximum }}
    + {{- end }} +
    {{.Required}}
    + +{{- end}}{{/* range .Types */}} +{{- end}}{{/* range .Kinds */}} +{{- end}}{{/* range .Groups */}} diff --git a/samples/Go Template/letter.tmpl b/samples/Go Template/letter.tmpl new file mode 100644 index 0000000000..ead07fe231 --- /dev/null +++ b/samples/Go Template/letter.tmpl @@ -0,0 +1,11 @@ +Dear {{.Name}}, +{{if .Attended}} +It was a pleasure to see you at the wedding. +{{- else}} +It is a shame you couldn't make it to the wedding. +{{- end}} +{{with .Gift -}} +Thank you for the lovely {{.}}. +{{end}} +Best wishes, +Josie diff --git a/samples/Go Template/prettier.html.tmpl b/samples/Go Template/prettier.html.tmpl new file mode 100644 index 0000000000..6c8c20675d --- /dev/null +++ b/samples/Go Template/prettier.html.tmpl @@ -0,0 +1,12 @@ +{{ if or .Prev .Next -}} + {{ $p := where site.Pages }} +
    + {{ with $p.Next . -}} + +
    +
    {{ .Title }}
    +
    +
    + {{ end -}} +
    +{{ end -}} diff --git a/samples/Smarty/header.tpl b/samples/Smarty/header.tpl new file mode 100644 index 0000000000..ff63c92151 --- /dev/null +++ b/samples/Smarty/header.tpl @@ -0,0 +1,6 @@ +{* Smarty example from https://github.com/smarty-php/smarty/blob/master/demo/templates/header.tpl *} + + +{$title} - {$Name} + + diff --git a/samples/Smarty/index.tpl b/samples/Smarty/index.tpl new file mode 100644 index 0000000000..a0f5ac36ca --- /dev/null +++ b/samples/Smarty/index.tpl @@ -0,0 +1,86 @@ +{* Smarty example from https://github.com/smarty-php/smarty/blob/master/demo/templates/index.tpl *} +{config_load file="test.conf" section="setup"} +{include file="header.tpl" title=foo} + +
    +
    +{* bold and title are read from the config file *}
    +    {if #bold#}{/if}
    +        {* capitalize the first letters of each word of the title *}
    +        Title: {#title#|capitalize}
    +        {if #bold#}{/if}
    +
    +    The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
    +
    +    Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
    +
    +    The value of {ldelim}$Name{rdelim} is {$Name}
    +
    +variable modifier example of {ldelim}$Name|upper{rdelim}
    +
    +{$Name|upper}
    +
    +
    +An example of a section loop:
    +
    +    {section name=outer
    +    loop=$FirstName}
    +        {if $smarty.section.outer.index is odd by 2}
    +            {$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
    +        {else}
    +            {$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
    +        {/if}
    +        {sectionelse}
    +        none
    +    {/section}
    +
    +    An example of section looped key values:
    +
    +    {section name=sec1 loop=$contacts}
    +        phone: {$contacts[sec1].phone}
    +        
    + + fax: {$contacts[sec1].fax} +
    + + cell: {$contacts[sec1].cell} +
    + {/section} +

    + + testing strip tags + {strip} + + + + +
    + + This is a test + +
    + {/strip} + +

    + +This is an example of the html_select_date function: + +
    + {html_select_date start_year=1998 end_year=2010} +
    + +This is an example of the html_select_time function: + +
    + {html_select_time use_24_hours=false} +
    + +This is an example of the html_options function: + +
    + +
    + +{include file="footer.tpl"} diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index a0effa0112..41852501f3 100755 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -1078,6 +1078,13 @@ def test_toc_by_heuristics }) end + def test_tpl_by_heuristics + assert_heuristics({ + "Go Template" => all_fixtures("Go Template", "*.tpl"), + "Smarty" => all_fixtures("Smarty", "*.tpl") + }) + end + def test_ts_by_heuristics assert_heuristics({ "TypeScript" => all_fixtures("TypeScript", "*.ts"), diff --git a/vendor/README.md b/vendor/README.md index a0ceb6b4e5..879c55835f 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -234,6 +234,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Go:** [tree-sitter/tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go) 🐌 - **Go Checksums:** [golang/vscode-go](https://github.com/golang/vscode-go) - **Go Module:** [golang/vscode-go](https://github.com/golang/vscode-go) +- **Go Template:** [jinliming2/vscode-go-template](https://github.com/jinliming2/vscode-go-template) - **Go Workspace:** [golang/vscode-go](https://github.com/golang/vscode-go) - **Godot Resource:** [godotengine/godot-vscode-plugin](https://github.com/godotengine/godot-vscode-plugin) - **Golo:** [TypeUnsafe/sublime-golo](https://github.com/TypeUnsafe/sublime-golo) diff --git a/vendor/grammars/vscode-go-template b/vendor/grammars/vscode-go-template new file mode 160000 index 0000000000..1ddab7c2d3 --- /dev/null +++ b/vendor/grammars/vscode-go-template @@ -0,0 +1 @@ +Subproject commit 1ddab7c2d3ef86fc4ea58df85d578d5da989d145 diff --git a/vendor/licenses/git_submodule/vscode-go-template.dep.yml b/vendor/licenses/git_submodule/vscode-go-template.dep.yml new file mode 100644 index 0000000000..5b298cded7 --- /dev/null +++ b/vendor/licenses/git_submodule/vscode-go-template.dep.yml @@ -0,0 +1,31 @@ +--- +name: vscode-go-template +version: 1ddab7c2d3ef86fc4ea58df85d578d5da989d145 +type: git_submodule +homepage: https://github.com/jinliming2/vscode-go-template.git +license: mit +licenses: +- sources: LICENSE + text: | + MIT License + + Copyright (c) 2021 Liming Jin + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +notices: []