1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-07 07:50:26 +00:00

fix: condition manually

Deekseek is silly
This commit is contained in:
lin onetwo 2024-08-03 01:05:49 +08:00
parent d0678716aa
commit b1667ecb9d

View File

@ -120,11 +120,24 @@ exports.parseIfClause = function(filterCondition) {
exports.serialize = function(tree, serialize) {
var filterCondition = tree.attributes.filter.value;
var ifClause = serialize(tree.children[0].children);
var elseClause = serialize(tree.children[1].children);
var serialized = '<% if ' + filterCondition + ' %>' + ifClause;
if(elseClause) {
serialized += '<% else %>' + elseClause;
var elseClause = tree.children[1].children;
var serialized = '<% if ' + filterCondition + '%>' + ifClause;
if(elseClause && elseClause.length > 0) {
for(var i = 0; i < elseClause.length; i++) {
if(elseClause[i].type === 'list' && elseClause[i].attributes.filter) {
// Handle elseif clause
var elseifCondition = elseClause[i].attributes.filter.value;
var elseifClause = serialize(elseClause[i].children[0]);
serialized += '<% elseif ' + elseifCondition + '%>' + elseifClause;
}
if(elseClause[i].children[1]) {
var elseClauseText = serialize(elseClause[i].children[1]);
serialized += '<% else %>' + elseClauseText;
}
}
}
serialized += '<% endif %>';
return serialized;
};