mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 12:57:05 +00:00
7.0.1 - https://github.com/iris-contrib/community-board/issues/1 https://github.com/iris-contrib/community-board/issues/2
Read HISTORY.md Former-commit-id: 82df2d266055818ffafe0ba66b58cf4ed9089922
This commit is contained in:
@@ -2,14 +2,49 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/kataras/iris/internal/cmd/gen/website/examples"
|
||||
"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.
|
||||
_, err := examples.WriteExamplesTo(os.Stdout) // doesn't work yet.
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user