Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '(?<!\{)\{(\*\s|\$|\/)?\w*\b'
- extensions: ['.ts']
rules:
- language: XML
Expand Down
16 changes: 16 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,22 @@ Go Module:
tm_scope: go.mod
ace_mode: text
language_id: 947461016
Go Template:
type: markup
color: "#00ADD8"
aliases:
- gotmpl
extensions:
- ".gohtml"
- ".gotmpl"
- ".html.tmpl"
- ".tmpl"
- ".tpl"
filenames:
- _helpers.tpl
tm_scope: source.go-template
ace_mode: text
language_id: 247918769
Go Workspace:
type: data
color: "#00ADD8"
Expand Down
8 changes: 8 additions & 0 deletions samples/Go Template/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- /* Generate basic labels */ -}}
{{- define "mychart.labels" }}
labels:
generator: helm
date: {{ now | htmlDate }}
chart: {{ .Chart.Name }}
version: {{ .Chart.Version }}
{{- end }}
71 changes: 71 additions & 0 deletions samples/Go Template/_templates.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{- /* https://github.com/redhat-cop/helm-charts/blob/main/_templates.gotmpl */ -}}

{{ define "doc.header" -}}

{{ template "chart.header" . }}
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

{{ template "chart.versionBadge" . }}

{{ template "chart.deprecationWarning" . }}

## Description

{{ template "chart.description" . }}

{{- end }}

{{ define "doc.maintainer_and_sources" -}}

{{ template "chart.maintainersSection" . }}

## Sources
Source: {{ template "chart.sourcesList" . }}

Source code: {{ template "chart.homepage" . }}

{{- end }}


{{ define "doc.deps" -}}

## Dependencies

This chart has the following dependencies:

{{ template "chart.requirementsTable" . }}

{{- end }}

{{ define "doc.values" -}}

{{ template "chart.valuesSection" . }}

{{- end }}


{{ define "doc.footer" -}}

## Installing the Chart

To install the chart with the release name `my-release`:

```console
helm install my-release repo/<chart-name>>
```

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 }}
36 changes: 36 additions & 0 deletions samples/Go Template/base.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ /* Example from https://github.com/go-echarts/go-echarts/blob/master/templates/base.tpl */ }}
{{- define "base_element" -}}
<div class="container">
<div class="item" id="{{ .ChartID }}" style="width:{{ .Initialization.Width }};height:{{ .Initialization.Height }};"></div>
</div>
{{- end -}}

{{- define "base_script" -}}
<script type="text/javascript">
"use strict";
let goecharts_{{ .ChartID | safeJS }} = echarts.init(document.getElementById('{{ .ChartID | safeJS }}'), "{{ .Theme }}", { renderer: "{{ .Initialization.Renderer }}" });
let option_{{ .ChartID | safeJS }} = {{ template "base_option" . }}
goecharts_{{ .ChartID | safeJS }}.setOption(option_{{ .ChartID | safeJS }});

{{- range $listener := .EventListeners }}
{{if .Query }}
goecharts_{{ $.ChartID | safeJS }}.on({{ $listener.EventName }}, {{ $listener.Query | safeJS }}, {{ injectInstance $listener.Handler "%MY_ECHARTS%" $.ChartID | safeJS }});
{{ else }}
goecharts_{{ $.ChartID | safeJS }}.on({{ $listener.EventName }}, {{ injectInstance $listener.Handler "%MY_ECHARTS%" $.ChartID | safeJS }})
{{ end }}
{{- end }}

{{- range .JSFunctions.Fns }}
{{ injectInstance . "%MY_ECHARTS%" $.ChartID | safeJS }}
{{- end }}
</script>
{{- end -}}

{{- define "base_option" }}
{{- .JSONNotEscaped | safeJS }}
{{- end }};

{{- define "base" }}
{{- template "base_element" . }}
{{- template "base_script" . }}
{{- end }}
57 changes: 57 additions & 0 deletions samples/Go Template/batch.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- /* https://github.com/ncruces/RethinkRAW/blob/master/assets/batch.gohtml */ -}}
<!doctype html>
<html lang=en>

<head>
<meta charset="utf-8">
<title>RethinkRAW: Batch processing {{len .Photos}} photos</title>
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="/main.css">
<link rel="stylesheet" href="/batch.css">
<link rel="stylesheet" href="/raw-editor.css">
<link rel="stylesheet" href="/dialog-polyfill.css">
<link rel="preload" as="style" href="/normalize.css">
<link rel="preload" as="style" href="/fontawesome.css">
<link rel="preload" as="font" type="font/woff2" crossorigin href="/fa-solid-900.woff2">
<script src="/dialog-polyfill.js" defer></script>
<script src="/main.js" defer></script>
<script src="/batch.js" defer></script>
<script src="/raw-editor.js" defer></script>
<noscript><meta http-equiv="refresh" content="0;url=/browser.html"></noscript>
</head>

<body>
{{- template "raw-editor.gohtml" "hidden"}}

<div id=menu-sticker>
<div id=menu>
<div class="toolbar">
<button type=button title="Go back" class="minimal-ui" onclick="back()"><i class="fas fa-arrow-left"></i></button>
<button type=button title="Reload photos" class="minimal-ui" onclick="location.reload()"><i class="fas fa-sync"></i></button>
<button type=button title="S̲ave changes" accesskey="s" onclick="saveFile()" id=save disabled><i class="fas fa-save"></i></button>
{{- if .Export}}
<button type=button title="Ex̲port JPEGs (⌥-click for options)" accesskey="x" class="alt-off" onclick="exportFile()"><i class="fas fa-file-image"></i></button>
<button type=button title="Export…" class="alt-on" onclick="exportFile('dialog')"><i class="fas fa-file-download"></i></button>
{{- end}}
<button type=button title="Edit photos…" onclick="toggleEdit()" id=edit><i class="fas fa-sliders-h"></i></button>
</div>
</div>
</div>
<div id=gallery>
{{- range .Photos}}
<a href="/photo/{{.Path}}" onclick="return popup(this, event)">
<img loading=lazy title="{{.Name}}" alt="{{.Name}}" src="/thumb/{{.Path}}" onerror="parentNode.hidden=true">
</a>
{{- else}}
<span>No RAW photos here.</span>
{{- end}}
</div>

<dialog id=progress-dialog>
Lorem ipsum<br>
<progress></progress>
</dialog>
</body>

</html>
110 changes: 110 additions & 0 deletions samples/Go Template/crd.tmpl
Original file line number Diff line number Diff line change
@@ -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}}
<sup><sup>[↩ Parent](#{{ anchorize (printf "%s/%s" $group.Group $group.Version) }} )</sup></sup>

{{range .Types}}

{{if not .IsTopLevel}}
### {{.Name}}
{{if .ParentKey}}<sup><sup>[↩ Parent](#{{.ParentKey}})</sup></sup>{{end}}
{{end}}


{{.Description}}

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody>
{{- if .IsTopLevel -}}
<tr>
<td><b>apiVersion</b></td>
<td>string</td>
<td>{{$group.Group}}/{{$group.Version}}</td>
<td>true</td>
</tr>
<tr>
<td><b>kind</b></td>
<td>string</td>
<td>{{$kind.Name}}</td>
<td>true</td>
</tr>
<tr>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td>
<td>object</td>
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
<td>true</td>
</tr>
{{- end -}}
{{- range .Fields -}}
<tr>
<td><b>{{if .TypeKey}}<a href="#{{.TypeKey}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}</b></td>
<td>{{.Type}}</td>
<td>
{{.Description}}<br/>
{{- if or .Schema.XValidations .Schema.Format .Schema.Enum .Schema.Default .Schema.Minimum .Schema.Maximum }}
<br/>
{{- end}}
{{- if .Schema.XValidations }}
<i>Validations</i>:
{{- range .Schema.XValidations -}}
<li>{{ .Rule }}: {{ .Message }}</li>
{{- end -}}
{{- end }}
{{- if .Schema.Format }}
<i>Format</i>: {{ .Schema.Format }}<br/>
{{- end }}
{{- if .Schema.Enum }}
<i>Enum</i>: {{ .Schema.Enum | toStrings | join ", " }}<br/>
{{- end }}
{{- if .Schema.Default }}
<i>Default</i>: {{ .Schema.Default }}<br/>
{{- end }}
{{- if .Schema.Minimum }}
<i>Minimum</i>: {{ .Schema.Minimum }}<br/>
{{- end }}
{{- if .Schema.Maximum }}
<i>Maximum</i>: {{ .Schema.Maximum }}<br/>
{{- end }}
</td>
<td>{{.Required}}</td>
</tr>
{{- end -}}
</tbody>
</table>

{{- end}}{{/* range .Types */}}
{{- end}}{{/* range .Kinds */}}
{{- end}}{{/* range .Groups */}}
11 changes: 11 additions & 0 deletions samples/Go Template/letter.tmpl
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions samples/Go Template/prettier.html.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ if or .Prev .Next -}}
{{ $p := where site.Pages }}
<div class="my-navigation">
{{ with $p.Next . -}}
<a href="{{ .RelPermalink }}">
<div class="row">
<div class="cell py-2">{{ .Title }}</div>
</div>
</a>
{{ end -}}
</div>
{{ end -}}
6 changes: 6 additions & 0 deletions samples/Smarty/header.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{* Smarty example from https://github.com/smarty-php/smarty/blob/master/demo/templates/header.tpl *}
<HTML>
<HEAD>
<TITLE>{$title} - {$Name}</TITLE>
</HEAD>
<BODY bgcolor="#ffffff">
Loading