mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
6282a71a6f
Read HISTORY.md Former-commit-id: 82df2d266055818ffafe0ba66b58cf4ed9089922
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"text/template"
|
|
|
|
"github.com/kataras/iris/internal/cmd/gen/website/recipe/example"
|
|
)
|
|
|
|
const tmpl = `
|
|
{{ range $key, $example := . -}}
|
|
{{ if $example.HasChildren }}
|
|
<h2 id="{{$example.Name}}"><a href="#{{$example.Name}}" class="headerlink" title="{{$example.Name}}"></a>{{$example.Name}}</h2>
|
|
{{ range $key, $child := $example.Children -}}
|
|
<h3 id="{{ $child.Name }}">
|
|
<a href="#{{ $child.Name }}" class="headerlink" title="{{ $child.Name }}"></a>
|
|
{{ $child.Name }}
|
|
</h3>
|
|
<pre data-src="{{ $child.DataSource }}"
|
|
data-visible="true" class ="line-numbers codepre"></pre>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{ if .HasNotChildren }}
|
|
<h2 id="{{ $example.Name }}">
|
|
<a href="#{{ $example.Name }}" class="headerlink" title="{{ $example.Name }}"></a>
|
|
{{ $example.Name }}
|
|
</h2>
|
|
<pre data-src="{{ $example.DataSource }}"
|
|
data-visible="true" class ="line-numbers codepre"></pre>
|
|
{{- end }}
|
|
{{- end }}
|
|
`
|
|
|
|
func main() {
|
|
// just for testing, the cli will be coded when I finish at least with this one command.
|
|
examples, err := example.Parse("master")
|
|
if err != nil {
|
|
println(err.Error())
|
|
return
|
|
}
|
|
|
|
text, err := template.New("").Parse(tmpl)
|
|
if err != nil {
|
|
println(err.Error())
|
|
}
|
|
|
|
if err := text.Execute(os.Stdout, examples); err != nil {
|
|
println("err in template : " + err.Error())
|
|
}
|
|
}
|