summaryrefslogtreecommitdiff
path: root/templ
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templ/form.tpl14
-rw-r--r--templ/login.tpl6
-rw-r--r--templ/login2.tpl4
-rw-r--r--templ/template.go7
4 files changed, 30 insertions, 1 deletions
diff --git a/templ/form.tpl b/templ/form.tpl
new file mode 100644
index 0000000..b17cb1d
--- /dev/null
+++ b/templ/form.tpl
@@ -0,0 +1,14 @@
+{{define "formItem"}}
+ <label {{with .ID}}for="{{.}}"{{end}}>{{.Label}}</label>
+ <input
+ {{with .ID}}id="{{.}}"{{end}}
+ type="{{.Type}}"
+ name="{{.Name}}"
+ placeholder="{{.Placeholder}}"
+ {{with .Value}}value="{{.}}"{{end}}
+ {{with .Class}}class="{{.}}"{{end}}
+ {{range .Options}} {{.}} {{end}}
+ >
+ {{with .Footer}}<p>{{.}}</p>{{end}}
+ <br />
+{{end}} \ No newline at end of file
diff --git a/templ/login.tpl b/templ/login.tpl
new file mode 100644
index 0000000..40d49c9
--- /dev/null
+++ b/templ/login.tpl
@@ -0,0 +1,6 @@
+{{define "body"}}
+ <form action="/login" method="post">
+ {{inputs_for .}}
+ <button type="submit">Log In!</button>
+ </form>
+{{end}} \ No newline at end of file
diff --git a/templ/login2.tpl b/templ/login2.tpl
new file mode 100644
index 0000000..89ba6a5
--- /dev/null
+++ b/templ/login2.tpl
@@ -0,0 +1,4 @@
+{{define "body"}}
+ Logged in with user: {{.Name}} <br>
+ You have chosen: {{.Password}}
+{{end}} \ No newline at end of file
diff --git a/templ/template.go b/templ/template.go
index 8fed965..20a4de7 100644
--- a/templ/template.go
+++ b/templ/template.go
@@ -4,6 +4,8 @@ import (
"embed"
"html/template"
"sync"
+
+ "github.com/Necoro/form"
)
//go:embed *.tpl
@@ -13,9 +15,12 @@ var templates = make(map[string]*template.Template)
var muTpl sync.RWMutex
var baseTpl *template.Template
+var formBuilder form.Builder
func init() {
- baseTpl = template.Must(template.ParseFS(fs, "base.tpl"))
+ baseTpl = template.Must(template.ParseFS(fs, "base.tpl", "form.tpl"))
+ formBuilder = form.Builder{InputTemplate: baseTpl.Lookup("formItem")}
+ baseTpl.Funcs(formBuilder.FuncMap())
}
func Lookup(name string) *template.Template {
+194 2010-03-14Rewrote Session as to use the normal ConfigParser and not our own oneRené 'Necoro' Neumann2-68/+50 2010-03-07Fix setup.pyRené 'Necoro' Neumann1-1/+1 2010-03-06Read translators from fileRené 'Necoro' Neumann4-9/+8 2010-03-06Updated NEWSRené 'Necoro' Neumann1-0/+3 2010-03-06Improved setup.py; also install the better-icon imageRené 'Necoro' Neumann1-8/+21 2010-03-06Only show best_icon, if the package can be installed w/o unmaskingRené 'Necoro' Neumann1-2/+2 2010-03-06Improved better_icon.René 'Necoro' Neumann1-78/+38 2010-03-06Show icon to signal the best package versionRené 'Necoro' Neumann1-1/+15 2010-03-06improved image handlingRené 'Necoro' Neumann2-7/+3 2010-03-05Use 'clear' instead of 'delete' for the search lineRené 'Necoro' Neumann1-1/+1 2010-03-05Corrected typoRené 'Necoro' Neumann6-9/+9 2010-03-05Updated german translationRené 'Necoro' Neumann2-538/+528 2010-03-05Reorderd parts of the menuRené 'Necoro' Neumann1-3/+3 2010-03-05Use existing translation for search typesRené 'Necoro' Neumann1-1/+1 2010-03-05Fixed bug in preference windowRené 'Necoro' Neumann1-2/+0 2010-03-05Fixed copyrightRené 'Necoro' Neumann66-66/+66 2010-03-05Handle portage warnings by our logging systemRené 'Necoro' Neumann1-0/+10 2010-03-05Ignore swap files in gitRené 'Necoro' Neumann1-0/+1 2010-03-05Clean up one 'deprecated' message from portageRené 'Necoro' Neumann1-1/+1 2010-03-05Save current search type in sessionRené 'Necoro' Neumann2-6/+17 2010-03-05Added combo box for selecting the search type to main windowRené 'Necoro' Neumann3-5/+43 2010-03-05Previous commits done more correct :PRené 'Necoro' Neumann2-6/+6 2010-03-05Fix commit 7449bc5fb8fRené 'Necoro' Neumann1-3/+3 2010-03-05Ignore swap files in gitRené 'Necoro' Neumann1-0/+1 2010-03-05Added some textual descriptionsRené 'Necoro' Neumann2-1/+8 2010-03-05Add description support to the databasesRené 'Necoro' Neumann4-8/+55 2010-03-04Also parse descriptions from eixRené 'Necoro' Neumann1-2/+2 2009-11-08Added Italian translation. Thanks to Ponsi.René 'Necoro' Neumann3-0/+1166 2009-11-05Remove the 'geneticize_list' stuff. It is so ancient, it stinks :PRené 'Necoro' Neumann1-19/+6