Skip to content

Commit 158c3fd

Browse files
committed
Improved sitemap calling.
1 parent dad4cf3 commit 158c3fd

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

internal.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,10 +1835,8 @@ function view_parse(content, minify, filename, controller) {
18351835
var builderTMP = '';
18361836
var sectionName = '';
18371837
var compileName = '';
1838-
var isSitemap = false;
18391838
var text;
18401839

1841-
18421840
while (command) {
18431841

18441842
if (old) {
@@ -1903,6 +1901,7 @@ function view_parse(content, minify, filename, controller) {
19031901
if (cmd.indexOf('foreach var ') !== -1)
19041902
cmd = cmd.replace(' var ', SPACE);
19051903

1904+
cmd = view_prepare_keywords(cmd);
19061905
newCommand = (cmd.substring(8, cmd.indexOf(SPACE, 8)) || '').trim();
19071906
index = cmd.trim().indexOf(SPACE, newCommand.length + 10);
19081907

@@ -1940,19 +1939,16 @@ function view_parse(content, minify, filename, controller) {
19401939
}
19411940

19421941
} else if (cmd.substring(0, 3) === 'if ') {
1943-
builder += ';if (' + cmd.substring(3) + '){$output+=$EMPTY';
1942+
builder += ';if (' + view_prepare_keywords(cmd).substring(3) + '){$output+=$EMPTY';
19441943
} else if (cmd7 === 'else if') {
1945-
builder += '} else if (' + cmd.substring(7) + ') {$output+=$EMPTY';
1944+
builder += '} else if (' + view_prepare_keywords(cmd).substring(7) + ') {$output+=$EMPTY';
19461945
} else if (cmd === 'else') {
19471946
builder += '} else {$output+=$EMPTY';
19481947
} else if (cmd === 'endif' || cmd === 'fi') {
19491948
builder += '}$output+=$EMPTY';
19501949
} else {
19511950

1952-
tmp = view_prepare(command.command, newCommand, functionsName, function() {
1953-
nocompress = true;
1954-
});
1955-
1951+
tmp = view_prepare(command.command, newCommand, functionsName, () => nocompress = true);
19561952
var can = false;
19571953

19581954
// Inline rendering is supported only in release mode
@@ -1999,8 +1995,6 @@ function view_parse(content, minify, filename, controller) {
19991995

20001996
old = command;
20011997
command = view_find_command(content, command.end);
2002-
if (command && command.command && command.command.indexOf('sitemap(') !== -1)
2003-
isSitemap = true;
20041998
}
20051999

20062000
if (old) {
@@ -2012,10 +2006,14 @@ function view_parse(content, minify, filename, controller) {
20122006
if (RELEASE)
20132007
builder = builder.replace(/(\+\$EMPTY\+)/g, '+').replace(/(\$output\=\$EMPTY\+)/g, '$output=').replace(/(\$output\+\=\$EMPTY\+)/g, '$output+=').replace(/(\}\$output\+\=\$EMPTY)/g, '}').replace(/(\{\$output\+\=\$EMPTY\;)/g, '{').replace(/(\+\$EMPTY\+)/g, '+').replace(/(\>\'\+\'\<)/g, '><').replace(/\'\+\'/g, '');
20142008

2015-
var fn = '(function(self,repository,model,session,query,body,url,global,helpers,user,config,functions,index,output,date,cookie,files,mobile){var get=query;var post=body;var theme=this.themeName;var language=this.language;var cookie=function(name){return controller.req.cookie(name);};' + (isSitemap ? 'var sitemap=function(){return self.sitemap.apply(self,arguments);};' : '') + (functions.length ? functions.join('') + ';' : '') + 'var controller=self;' + builder + ';return $output;})';
2009+
var fn = '(function(self,repository,model,session,query,body,url,global,helpers,user,config,functions,index,output,date,cookie,files,mobile){var get=query;var post=body;var theme=this.themeName;var language=this.language;var cookie=function(name){return controller.req.cookie(name);};' + (functions.length ? functions.join('') + ';' : '') + 'var controller=self;' + builder + ';return $output;})';
20162010
return eval(fn);
20172011
}
20182012

2013+
function view_prepare_keywords(cmd) {
2014+
return cmd.replace(/\s+(sitemap_navigation\(|sitemap\()+/g, text => ' self.' + text.trim());
2015+
}
2016+
20192017
function wrapTryCatch(value, command, line) {
20202018
if (!framework.isDebug)
20212019
return value;

0 commit comments

Comments
 (0)