Module:TemplateHelpers: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 268: Line 268:
         items = p.splitMultiValueString(value)
         items = p.splitMultiValueString(value)
     end
     end
   
    -- For non-SMW case, collect property HTML fragments in a table for efficient concatenation
    local propertyHtml = {}
      
      
     -- Process each item and add as a semantic property
     -- Process each item and add as a semantic property
Line 285: Line 288:
                 mw.smw.set({[propertyName] = processedItem})
                 mw.smw.set({[propertyName] = processedItem})
             else
             else
                 semanticOutput = semanticOutput .. "\n" ..
                 -- Collect HTML fragments instead of concatenating strings
                    '<div style="display:none;">\n {{#set: ' .. propertyName .. '=' ..  
                table.insert(propertyHtml, '<div style="display:none;">')
                    processedItem .. ' }}\n</div>'
                table.insert(propertyHtml, ' {{#set: ' .. propertyName .. '=' .. processedItem .. ' }}')
                table.insert(propertyHtml, '</div>')
             end
             end
         end
         end
    end
   
    -- For non-SMW case, concatenate all property HTML fragments at once
    if not mw.smw and #propertyHtml > 0 then
        semanticOutput = semanticOutput .. "\n" .. table.concat(propertyHtml, "\n")
     end
     end
      
      
Line 387: Line 396:
      
      
     skipProperties = skipProperties or {}
     skipProperties = skipProperties or {}
   
    -- For non-SMW case, collect property HTML fragments in a table for efficient concatenation
    local propertyHtml = {}
      
      
     for property, sourceFields in pairs(semanticConfig.additionalProperties) do
     for property, sourceFields in pairs(semanticConfig.additionalProperties) do
Line 414: Line 426:
                             mw.smw.set({[property] = value})
                             mw.smw.set({[property] = value})
                         else
                         else
                             semanticOutput = semanticOutput .. "\n" ..
                             -- Collect HTML fragments instead of concatenating strings
                                '<div style="display:none;">\n {{#set: ' .. property .. '=' ..  
                            table.insert(propertyHtml, '<div style="display:none;">')
                                value .. ' }}\n</div>'
                            table.insert(propertyHtml, ' {{#set: ' .. property .. '=' .. value .. ' }}')
                            table.insert(propertyHtml, '</div>')
                         end
                         end
                     end
                     end
Line 422: Line 435:
             end
             end
         end
         end
    end
   
    -- For non-SMW case, concatenate all property HTML fragments at once
    if not mw.smw and #propertyHtml > 0 then
        semanticOutput = semanticOutput .. "\n" .. table.concat(propertyHtml, "\n")
     end
     end