save bytes in client templates
This commit is contained in:
parent
5419af9c1c
commit
75ed0cd5f2
@ -185,13 +185,18 @@ func (list SFileList) JSTmplInit() error {
|
|||||||
data = replace(data, " c.", "")
|
data = replace(data, " c.", "")
|
||||||
data = replace(data, "phrases.", "")
|
data = replace(data, "phrases.", "")
|
||||||
data = replace(data, ", 10;", "")
|
data = replace(data, ", 10;", "")
|
||||||
|
|
||||||
//data = replace(data, "var plist = GetTmplPhrasesBytes("+shortName+"_tmpl_phrase_id)", "const plist = tmplPhrases[\""+tmplName+"\"];")
|
//data = replace(data, "var plist = GetTmplPhrasesBytes("+shortName+"_tmpl_phrase_id)", "const plist = tmplPhrases[\""+tmplName+"\"];")
|
||||||
data = replace(data, "//var plist = GetTmplPhrasesBytes("+shortName+"_tmpl_phrase_id)", "const "+shortName+"_phrase_arr = tmplPhrases[\""+tmplName+"\"];")
|
//data = replace(data, "//var plist = GetTmplPhrasesBytes("+shortName+"_tmpl_phrase_id)", "const "+shortName+"_phrase_arr = tmplPhrases[\""+tmplName+"\"];")
|
||||||
data = replace(data, "var cached_var_", "let cached_var_")
|
data = replace(data, "//var plist = GetTmplPhrasesBytes("+shortName+"_tmpl_phrase_id)", "const pl=tmplPhrases[\""+tmplName+"\"];")
|
||||||
data = replace(data, `tmpl_vars, ok := tmpl_i.`, `/*`)
|
data = replace(data, shortName+"_phrase_arr", "pl")
|
||||||
|
data = replace(data, "tmpl_"+shortName+"_vars", "t_vars")
|
||||||
|
|
||||||
|
data = replace(data, "var c_var_", "let c_var_")
|
||||||
|
data = replace(data, `t_vars, ok := tmpl_i.`, `/*`)
|
||||||
data = replace(data, "[]byte(", "")
|
data = replace(data, "[]byte(", "")
|
||||||
data = replace(data, "StringToBytes(", "")
|
data = replace(data, "StringToBytes(", "")
|
||||||
data = replace(data, "RelativeTime(tmpl_"+shortName+"_vars.", "tmpl_"+shortName+"_vars.Relative")
|
data = replace(data, "RelativeTime(t_vars.", "t_vars.Relative")
|
||||||
// TODO: Format dates properly on the client side
|
// TODO: Format dates properly on the client side
|
||||||
data = replace(data, ".Format(\"2006-01-02 15:04:05\"", "")
|
data = replace(data, ".Format(\"2006-01-02 15:04:05\"", "")
|
||||||
data = replace(data, ", 10", "")
|
data = replace(data, ", 10", "")
|
||||||
@ -239,7 +244,7 @@ func (list SFileList) JSTmplInit() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
// Don't use Gzip if we get meagre gains from it as it takes longer to process the responses
|
||||||
if len(gzipData) >= (len(data) + 150) {
|
if len(gzipData) >= (len(data) + 120) {
|
||||||
gzipData = nil
|
gzipData = nil
|
||||||
} else {
|
} else {
|
||||||
diff := len(data) - len(gzipData)
|
diff := len(data) - len(gzipData)
|
||||||
|
@ -1959,7 +1959,7 @@ func (c *CTemplateSet) afterTemplate(con CContext, startIndex int) {
|
|||||||
varmap := make(map[string]int)
|
varmap := make(map[string]int)
|
||||||
for name, count := range varcounts {
|
for name, count := range varcounts {
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
varstr += "var cached_var_" + strconv.Itoa(i) + " = " + name + "\n"
|
varstr += "var c_var_" + strconv.Itoa(i) + "=" + name + "\n"
|
||||||
varmap[name] = i
|
varmap[name] = i
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
@ -1979,7 +1979,7 @@ func (c *CTemplateSet) afterTemplate(con CContext, startIndex int) {
|
|||||||
} else if item.Type == "varsub" && loopDepth == 0 {
|
} else if item.Type == "varsub" && loopDepth == 0 {
|
||||||
index, ok := varmap[item.Body]
|
index, ok := varmap[item.Body]
|
||||||
if ok {
|
if ok {
|
||||||
item.Body = "cached_var_" + strconv.Itoa(index)
|
item.Body = "c_var_" + strconv.Itoa(index)
|
||||||
item.Type = "cvarsub"
|
item.Type = "cvarsub"
|
||||||
outBuf[i] = item
|
outBuf[i] = item
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
|
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
|
||||||
</div>
|
</div>
|
||||||
{{else}}<div class="opt locked_opt" title="{{lang "topics_locked_tooltip"}}" aria-label="{{lang "topics_locked_aria"}}"><a></a></div>{{end}}
|
{{else}}<div class="opt locked_opt" title="{{lang "topics_locked_tooltip"}}" aria-label="{{lang "topics_locked_aria"}}"><a></a></div>{{end}}
|
||||||
</div>
|
</div><div style="clear:both;"></div>
|
||||||
<div style="clear:both;"></div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user