Hopefully this'll work.

This commit is contained in:
Azareal 2018-05-14 20:59:18 +10:00
parent a78613b63b
commit c6de9b92be
6 changed files with 67 additions and 99 deletions

View File

@ -39,13 +39,13 @@ type CSSData struct {
func (list SFileList) JSTmplInit() error {
var fragMap = make(map[string][][]byte)
fragMap["alert"] = tmpl.Get_alert_frags() // TODO: Add a generic fetch function, so we don't rely on the presence of the template files for this
fragMap["alert"] = tmpl.GetFrag("alert")
fmt.Println("fragMap: ", fragMap)
return filepath.Walk("./tmpl_client", func(path string, f os.FileInfo, err error) error {
if f.IsDir() {
return nil
}
if strings.HasSuffix(path, "template_list.go") {
if strings.HasSuffix(path, "template_list.go") || strings.HasSuffix(path, "stub.go") {
return nil
}

View File

@ -343,11 +343,14 @@ func writeTemplateList(c *tmpl.CTemplateSet, wg *sync.WaitGroup, prefix string)
wg.Add(1)
go func() {
out := "package " + c.GetConfig().PackageName + "\n\n"
var getterstr = "\n// nolint\nGetFrag = func(name string) [][]byte {\nswitch(name) {\n"
for templateName, count := range c.TemplateFragmentCount {
out += "var " + templateName + "_frags = make([][]byte," + strconv.Itoa(count) + ")\n"
out += "\n// nolint\nfunc Get_" + templateName + "_frags() [][]byte {\nreturn " + templateName + "_frags\n}\n"
getterstr += "\tcase \"" + templateName + "\":\n"
getterstr += "\treturn " + templateName + "_frags\n"
}
out += "\n// nolint\nfunc init() {\n" + c.FragOut + "}\n"
getterstr += "}\nreturn nil\n}\n"
out += "\n// nolint\nfunc init() {\n" + c.FragOut + "\n" + getterstr + "}\n"
err := writeFile(prefix+"template_list.go", out)
if err != nil {
log.Fatal(err)

View File

@ -1,101 +1,21 @@
package main
var error_frags = make([][]byte,4)
// nolint
func Get_error_frags() [][]byte {
return error_frags
}
var profile_comments_row_frags = make([][]byte,51)
// nolint
func Get_profile_comments_row_frags() [][]byte {
return profile_comments_row_frags
}
var topic_alt_frags = make([][]byte,200)
// nolint
func Get_topic_alt_frags() [][]byte {
return topic_alt_frags
}
var profile_frags = make([][]byte,50)
// nolint
func Get_profile_frags() [][]byte {
return profile_frags
}
var ip_search_frags = make([][]byte,18)
// nolint
func Get_ip_search_frags() [][]byte {
return ip_search_frags
}
var header_frags = make([][]byte,26)
// nolint
func Get_header_frags() [][]byte {
return header_frags
}
var forums_frags = make([][]byte,26)
// nolint
func Get_forums_frags() [][]byte {
return forums_frags
}
var login_frags = make([][]byte,8)
// nolint
func Get_login_frags() [][]byte {
return login_frags
}
var register_frags = make([][]byte,9)
// nolint
func Get_register_frags() [][]byte {
return register_frags
}
var footer_frags = make([][]byte,13)
// nolint
func Get_footer_frags() [][]byte {
return footer_frags
}
var topic_frags = make([][]byte,199)
// nolint
func Get_topic_frags() [][]byte {
return topic_frags
}
var paginator_frags = make([][]byte,16)
// nolint
func Get_paginator_frags() [][]byte {
return paginator_frags
}
var topics_frags = make([][]byte,98)
// nolint
func Get_topics_frags() [][]byte {
return topics_frags
}
var forum_frags = make([][]byte,90)
// nolint
func Get_forum_frags() [][]byte {
return forum_frags
}
var guilds_guild_list_frags = make([][]byte,10)
// nolint
func Get_guilds_guild_list_frags() [][]byte {
return guilds_guild_list_frags
}
var notice_frags = make([][]byte,3)
// nolint
func Get_notice_frags() [][]byte {
return notice_frags
}
var forums_frags = make([][]byte,26)
var paginator_frags = make([][]byte,16)
var forum_frags = make([][]byte,90)
var guilds_guild_list_frags = make([][]byte,10)
var header_frags = make([][]byte,26)
var topic_alt_frags = make([][]byte,200)
var topics_frags = make([][]byte,98)
var topic_frags = make([][]byte,199)
var profile_comments_row_frags = make([][]byte,51)
var register_frags = make([][]byte,9)
var ip_search_frags = make([][]byte,18)
var footer_frags = make([][]byte,13)
var profile_frags = make([][]byte,50)
var error_frags = make([][]byte,4)
// nolint
func init() {
@ -1757,4 +1677,44 @@ guilds_guild_list_frags[8] = []byte(`
</div>
</main>
`)
// nolint
GetFrag = func(name string) [][]byte {
switch(name) {
case "login":
return login_frags
case "notice":
return notice_frags
case "forums":
return forums_frags
case "paginator":
return paginator_frags
case "forum":
return forum_frags
case "guilds_guild_list":
return guilds_guild_list_frags
case "header":
return header_frags
case "topic_alt":
return topic_alt_frags
case "topics":
return topics_frags
case "topic":
return topic_frags
case "profile_comments_row":
return profile_comments_row_frags
case "register":
return register_frags
case "ip_search":
return ip_search_frags
case "footer":
return footer_frags
case "profile":
return profile_frags
case "error":
return error_frags
}
return nil
}
}

View File

@ -1 +0,0 @@
This file is here so that Git will include this folder in the repository.

3
tmpl_client/stub.go Normal file
View File

@ -0,0 +1,3 @@
package tmpl
var GetFrag func(name string) [][]byte

3
tmpl_stub.go Normal file
View File

@ -0,0 +1,3 @@
package main
var GetFrag func(name string) [][]byte