Optimize SUI core to load script with disableCache option
This commit is contained in:
parent
99a77fdd8e
commit
5050443e63
2 changed files with 7 additions and 4 deletions
|
|
@ -277,7 +277,7 @@ func (parser *TemplateParser) parseElementComponent(sel *goquery.Selection) {
|
||||||
if parser.option.Imports != nil {
|
if parser.option.Imports != nil {
|
||||||
if route, has := parser.option.Imports[com]; has {
|
if route, has := parser.option.Imports[com]; has {
|
||||||
file := filepath.Join(string(os.PathSeparator), "public", parser.option.Root, route)
|
file := filepath.Join(string(os.PathSeparator), "public", parser.option.Root, route)
|
||||||
script, err = LoadScript(file)
|
script, err = LoadScript(file, parser.disableCache())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
parser.errors = append(parser.errors, err)
|
parser.errors = append(parser.errors, err)
|
||||||
setError(sel, err)
|
setError(sel, err)
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,14 @@ func scriptWriter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadScript load the script
|
// LoadScript load the script
|
||||||
func LoadScript(file string) (*Script, error) {
|
func LoadScript(file string, disableCache ...bool) (*Script, error) {
|
||||||
|
|
||||||
base := strings.TrimSuffix(strings.TrimSuffix(file, ".sui"), ".jit")
|
base := strings.TrimSuffix(strings.TrimSuffix(file, ".sui"), ".jit")
|
||||||
if script, has := Scripts[base]; has {
|
// LOAD FROM CACHE
|
||||||
return script, nil
|
if disableCache == nil || !disableCache[0] {
|
||||||
|
if script, has := Scripts[base]; has {
|
||||||
|
return script, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file = base + ".ts"
|
file = base + ".ts"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue