Module:SemanticAnnotations: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 1: Line 1:
-- Module:SemanticAnnotations
-- Module:SemanticAnnotations
-- Generates semantic annotations for templates
-- Generates semantic annotations for templates in MediaWiki
-- Compatible with Semantic MediaWiki, Semantic Scribunto, Semantic Drilldown, and DynamicPageList3
-- Docs: https://github.com/SemanticMediaWiki/SemanticScribunto/tree/master/docs
-- Docs: https://github.com/SemanticMediaWiki/SemanticScribunto/tree/master/docs


local p = {}
local p = {}


-- Private helper function to trim whitespace
-- Trim whitespace helper
local function trim(s)
local function trim(s) return (s:gsub("^%s+", ""):gsub("%s+$", "")) end
    return (s:gsub("^%s+", ""):gsub("%s+$", ""))
end


--[[
--[[ Generates semantic annotations using #set parser function
    Generates semantic annotations using SMW's #set parser function.
  @param args - Template parameters table
    This function now handles both legacy string mappings and new complex mappings.
  @param mappings - Property mappings: {["Property"] = "param"} or complex format
   
  @param options - Config options (visible, prefix, transform, default, conditional)
    @param args     - Template parameters table
  @return Wikitext string containing semantic annotations
    @param mappings - Property to parameter mappings in any of these formats:
                      1. Simple string: {["Property"] = "param_name"}
                      2. Object with param: {["Property"] = {param = "param_name"}}
                      3. Object with multiple mappings: {["Property"] = {mappings = [{param = "p1", metadata = {...}}, ...]}}
    @param options - Configuration options:
                    {
                      visible = false,   -- Show annotations (default: false)
                      prefix = "",       -- Property prefix
                      transform = {},   -- Transform functions: {["Property"] = function(val) ... end}
                      default = {},     -- Default values: {["Property"] = "default"}
                      conditional = {},  -- Conditional mappings: {["Property"] = {param="x", value="y"}}
                    }
   
    @return Wikitext string containing semantic annotations
]]
]]
function p.generateAnnotations(args, mappings, options)
function p.generateAnnotations(args, mappings, options)
     -- For complex mappings, just delegate to generateEnhancedAnnotations
     -- If complex mappings found, delegate to enhanced function
     if mappings and type(mappings) == "table" then
     if mappings and type(mappings) == "table" then
         for _, mapping in pairs(mappings) do
         for _, mapping in pairs(mappings) do
             if type(mapping) == "table" then
             if type(mapping) == "table" then return p.generateEnhancedAnnotations(args, mappings, options) end
                -- Found at least one complex mapping, use the enhanced function
                return p.generateEnhancedAnnotations(args, mappings, options)
            end
         end
         end
     end
     end
      
      
     -- If we got here, all mappings are simple string mappings
     -- Initialize with defaults
     args = args or {}
     args = args or {}
     mappings = mappings or {}
     mappings = mappings or {}
     options = options or {}
     options = options or {}
   
    -- Set defaults for options
     local visible = options.visible or false
     local visible = options.visible or false
     local prefix = options.prefix or ""
     local prefix = options.prefix or ""
Line 54: Line 32:
     local conditional = options.conditional or {}
     local conditional = options.conditional or {}
      
      
     -- Start building the annotation block
     -- Build annotation block
     local result = {}
     local result = {}
   
     if not visible then table.insert(result, '<div style="display:none;">') end
    -- Determine if we need the hidden div wrapper
     if not visible then
        table.insert(result, '<div style="display:none;">')
    end
   
    -- Start the #set parser function
     table.insert(result, '  {{#set:')
     table.insert(result, '  {{#set:')
   
    -- Process all property mappings
     local propertyCount = 0
     local propertyCount = 0
      
      
     -- Handle regular property mappings (legacy string-to-string format)
     -- Process string mappings
     for property, param in pairs(mappings) do
     for property, param in pairs(mappings) do
        -- Only process string params (skip tables which are handled by enhanced function)
         if type(param) == "string" then
         if type(param) == "string" then
             local fullPropertyName = prefix .. property
             local fullPropertyName = prefix .. property
             local value = args[param]
             local value = args[param]
              
              
             -- Apply transform if one exists for this property
             -- Apply transform if exists
             if value and transform[property] then
             if value and transform[property] then value = transform[property](value) end
                value = transform[property](value)
            end
              
              
             -- Use the value if it exists, otherwise use default if provided
             -- Add property if value exists or default provided
             if value and value ~= "" then
             if value and value ~= "" then
                 table.insert(result, string.format('    |%s=%s', fullPropertyName, value))
                 table.insert(result, string.format('    |%s=%s', fullPropertyName, value))
Line 91: Line 58:
     end
     end
      
      
     -- Handle conditional properties
     -- Process conditional properties
     for property, condition in pairs(conditional) do
     for property, condition in pairs(conditional) do
         local fullPropertyName = prefix .. property
         local fullPropertyName = prefix .. property
Line 100: Line 67:
     end
     end
      
      
     -- Close the #set parser function
     -- Close the parser function and wrapper
     table.insert(result, '  }}')
     table.insert(result, '  }}')
    if not visible then table.insert(result, '</div>') end
      
      
     -- Close the hidden div if we're using it
     -- Return result or empty string
    if not visible then
     return propertyCount > 0 and table.concat(result, "\n") or ""
        table.insert(result, '</div>')
    end
   
    -- If no properties were set, return an empty string
     if propertyCount == 0 then
        return ""
    end
   
    -- Join all lines and return
    return table.concat(result, "\n")
end
end


--[[
-- Renders a table using TemplateStructure and adds annotations
    Renders a table using TemplateStructure and adds semantic annotations.
   
    @param args            - Template parameters
    @param config          - TemplateStructure configuration
    @param semanticMappings - Property to parameter mappings
    @param semanticOptions  - Annotation configuration options
   
    @return Rendered template with semantic annotations
]]
function p.renderWithSemantics(args, config, semanticMappings, semanticOptions)
function p.renderWithSemantics(args, config, semanticMappings, semanticOptions)
     local TemplateStructure = require('Module:TemplateStructure')
     local TemplateStructure = require('Module:TemplateStructure')
   
    -- Render the table structure
     local renderedTable = TemplateStructure.render(args, config)
     local renderedTable = TemplateStructure.render(args, config)
   
    -- Generate the semantic annotations
     local annotations = p.generateAnnotations(args, semanticMappings, semanticOptions)
     local annotations = p.generateAnnotations(args, semanticMappings, semanticOptions)
   
    -- Combine and return
     return renderedTable .. "\n" .. annotations
     return renderedTable .. "\n" .. annotations
end
end


-- Allows templates to append semantic annotations directly via transclusion
-- Allows templates to append annotations directly via transclusion
function p.appendToTemplate(frame)
function p.appendToTemplate(frame)
     local args = frame.args
     local args = frame.args
Line 146: Line 89:
     local parentArgs = parent and parent.args or {}
     local parentArgs = parent and parent.args or {}
      
      
     -- Mapping is defined as pairs of properties and parameters
     -- Build mappings from numbered parameters
     local mappings = {}
     local mappings = {}
     local i = 1
     local i = 1
   
     while args["property" .. i] and args["param" .. i] do
     while args["property" .. i] and args["param" .. i] do
         mappings[args["property" .. i]] = args["param" .. i]
         mappings[args["property" .. i]] = args["param" .. i]
Line 155: Line 97:
     end
     end
      
      
     -- Extract options
     -- Extract options and generate annotations
     local options = {
     local options = {
         visible = args.visible == "true",
         visible = args.visible == "true",
         prefix = args.prefix or ""
         prefix = args.prefix or ""
     }
     }
   
    -- Generate and return the annotations
     return p.generateAnnotations(parentArgs, mappings, options)
     return p.generateAnnotations(parentArgs, mappings, options)
end
end


-- Helper function for processing a simple property mapping
-- Process simple property mapping
local function processSimpleMapping(properties, propertyName, value, transformFunc, defaultValue)
local function processSimpleMapping(properties, propertyName, value, transformFunc, defaultValue)
     -- Apply transform if one exists and we have a value
     -- Apply transform if applicable
     if value and value ~= "" and transformFunc then
     if value and value ~= "" and transformFunc then value = transformFunc(value) end
        value = transformFunc(value)
    end
      
      
     -- Use value if it exists, otherwise use default
     -- Handle value setting with array conversion if needed
     if value and value ~= "" then
     if value and value ~= "" then
        -- If property already exists, convert to array or append
         if properties[propertyName] then
         if properties[propertyName] then
             -- Convert to array if it's the first duplicate
             -- Convert to array if first duplicate
             if type(properties[propertyName]) ~= "table" then
             if type(properties[propertyName]) ~= "table" then
                 properties[propertyName] = {properties[propertyName]}
                 properties[propertyName] = {properties[propertyName]}
             end
             end
            -- Append new value
             table.insert(properties[propertyName], value)
             table.insert(properties[propertyName], value)
         else
         else
            -- First value for this property
             properties[propertyName] = value
             properties[propertyName] = value
         end
         end
Line 191: Line 126:
end
end


-- Helper function for processing a complex property mapping with metadata
-- Process complex property mapping with metadata
local function processComplexMapping(properties, propertyName, args, mappings, transformFunc)
local function processComplexMapping(properties, propertyName, args, mappings, transformFunc)
     for _, mappingEntry in ipairs(mappings) do
     for _, mappingEntry in ipairs(mappings) do
Line 198: Line 133:
         local value = args[param]
         local value = args[param]
          
          
        -- Process only if value exists
         if value and value ~= "" then
         if value and value ~= "" then
             -- Apply transform if available - make sure we use the right scoped transform function
             -- Apply transform
             if transformFunc then
             if transformFunc then value = transformFunc(value) end
                -- Apply the transformation
                value = transformFunc(value)
            end
              
              
             -- Add metadata qualifiers to property name if metadata exists
             -- Handle metadata qualifiers
             local qualifiedProperty = propertyName
             local qualifiedProperty = propertyName
             if next(metadata) then
             if next(metadata) then
Line 213: Line 144:
                     table.insert(qualifiers, metaKey .. "=" .. metaValue)
                     table.insert(qualifiers, metaKey .. "=" .. metaValue)
                 end
                 end
                -- Sort for consistency
                 table.sort(qualifiers)
                 table.sort(qualifiers)
                 qualifiedProperty = propertyName .. "#" .. table.concat(qualifiers, ";")
                 qualifiedProperty = propertyName .. "#" .. table.concat(qualifiers, ";")
             end
             end
              
              
             -- Set the property with qualified name
             -- Set property with array handling
             if properties[qualifiedProperty] then
             if properties[qualifiedProperty] then
                -- Convert to array if it's the first duplicate
                 if type(properties[qualifiedProperty]) ~= "table" then
                 if type(properties[qualifiedProperty]) ~= "table" then
                     properties[qualifiedProperty] = {properties[qualifiedProperty]}
                     properties[qualifiedProperty] = {properties[qualifiedProperty]}
                 end
                 end
                -- Append new value
                 table.insert(properties[qualifiedProperty], value)
                 table.insert(properties[qualifiedProperty], value)
             else
             else
                -- First value for this property
                 properties[qualifiedProperty] = value
                 properties[qualifiedProperty] = value
             end
             end
         end
         end
        -- No need for goto continue - just continue the loop naturally
     end
     end
end
end


-- Helper function for adding a simple property to parser function result
-- Add simple property to parser function result
local function addSimplePropertyToResult(result, propertyName, value, transformFunc, defaultValue)
local function addSimplePropertyToResult(result, propertyName, value, transformFunc, defaultValue)
    -- Apply transform if one exists and we have a value
     if value and value ~= "" and transformFunc then value = transformFunc(value) end
     if value and value ~= "" and transformFunc then
        value = transformFunc(value)
    end
      
      
    -- Use value if it exists, otherwise use default
     if value and value ~= "" then
     if value and value ~= "" then
         table.insert(result, string.format('    |%s=%s', propertyName, value))
         table.insert(result, string.format('    |%s=%s', propertyName, value))
Line 250: Line 172:
         return 1
         return 1
     end
     end
   
     return 0
     return 0
end
end


--[[
-- Enhanced version supporting complex mappings (fallback when mw.smw unavailable)
    Enhanced version of generateAnnotations that supports complex mappings
    Used as fallback when mw.smw is not available
]]
function p.generateEnhancedAnnotations(args, mappings, options)
function p.generateEnhancedAnnotations(args, mappings, options)
     args = args or {}
     args = args or {}
Line 263: Line 181:
     options = options or {}
     options = options or {}
      
      
     -- Set defaults for options
     -- Initialize with defaults
     local visible = options.visible or false
     local visible = options.visible or false
     local prefix = options.prefix or ""
     local prefix = options.prefix or ""
Line 270: Line 188:
     local conditional = options.conditional or {}
     local conditional = options.conditional or {}
      
      
     -- Start building the annotation block
     -- Build annotation block
     local result = {}
     local result = {}
   
     if not visible then table.insert(result, '<div style="display:none;">') end
    -- Determine if we need the hidden div wrapper
     if not visible then
        table.insert(result, '<div style="display:none;">')
    end
   
    -- Start the #set parser function
     table.insert(result, '  {{#set:')
     table.insert(result, '  {{#set:')
   
    -- Process all property mappings
     local propertyCount = 0
     local propertyCount = 0
      
      
     -- Generate property sets for parser function
     -- Process all property types
     for property, mapping in pairs(mappings) do
     for property, mapping in pairs(mappings) do
         local fullPropertyName = prefix .. property
         local fullPropertyName = prefix .. property
          
          
        -- Handle different mapping types
         if type(mapping) == "string" then
         if type(mapping) == "string" then
             -- Legacy simple string mapping
             -- Simple string mapping
             propertyCount = propertyCount + addSimplePropertyToResult(result,  
             propertyCount = propertyCount + addSimplePropertyToResult(result,  
                 fullPropertyName, args[mapping], transform[property], default[property])
                 fullPropertyName, args[mapping], transform[property], default[property])
         elseif type(mapping) == "table" then
         elseif type(mapping) == "table" then
             if mapping.param then
             if mapping.param then
                 -- Single mapping with object structure
                 -- Object with param structure
                 propertyCount = propertyCount + addSimplePropertyToResult(result,  
                 propertyCount = propertyCount + addSimplePropertyToResult(result,  
                     fullPropertyName, args[mapping.param], transform[property], default[property])
                     fullPropertyName, args[mapping.param], transform[property], default[property])
Line 305: Line 214:
                     local value = args[param]
                     local value = args[param]
                      
                      
                    -- Process only if value exists
                     if value and value ~= "" then
                     if value and value ~= "" then
                         -- Apply transform if available
                         -- Apply transform
                         if transform[property] then
                         if transform[property] then value = transform[property](value) end
                            value = transform[property](value)
                        end
                          
                          
                         -- Add metadata qualifiers to property name if metadata exists
                         -- Add metadata qualifiers
                         local qualifiedProperty = fullPropertyName
                         local qualifiedProperty = fullPropertyName
                         if next(metadata) then
                         if next(metadata) then
Line 319: Line 225:
                                 table.insert(qualifiers, metaKey .. "=" .. metaValue)
                                 table.insert(qualifiers, metaKey .. "=" .. metaValue)
                             end
                             end
                            -- Sort for consistency
                             table.sort(qualifiers)
                             table.sort(qualifiers)
                             qualifiedProperty = fullPropertyName .. "#" .. table.concat(qualifiers, ";")
                             qualifiedProperty = fullPropertyName .. "#" .. table.concat(qualifiers, ";")
                         end
                         end
                          
                          
                         -- Add the property to result
                         -- Add property to result
                         table.insert(result, string.format('    |%s=%s', qualifiedProperty, value))
                         table.insert(result, string.format('    |%s=%s', qualifiedProperty, value))
                         propertyCount = propertyCount + 1
                         propertyCount = propertyCount + 1
Line 333: Line 238:
     end
     end
      
      
     -- Handle conditional properties (maintain backwards compatibility)
     -- Handle conditional properties
     for property, condition in pairs(conditional) do
     for property, condition in pairs(conditional) do
         local fullPropertyName = prefix .. property
         local fullPropertyName = prefix .. property
Line 342: Line 247:
     end
     end
      
      
     -- Close the #set parser function
     -- Close parser function and wrapper
     table.insert(result, '  }}')
     table.insert(result, '  }}')
    if not visible then table.insert(result, '</div>') end
      
      
     -- Close the hidden div if we're using it
     -- Return result or empty string
    if not visible then
     return propertyCount > 0 and table.concat(result, "\n") or ""
        table.insert(result, '</div>')
    end
   
    -- If no properties were set, return an empty string
     if propertyCount == 0 then
        return ""
    end
   
    -- Join all lines and return
    return table.concat(result, "\n")
end
end


--[[
--[[ Sets semantic properties with native API or fallback
    Enhanced version of setSemanticProperties that supports complex mappings
  @param args - Template parameters
   
  @param mappings - Property mappings in various formats:
    @param args     - Template parameters
    - Simple: {["Property"] = "param_name"}
    @param mappings - Property to parameter mappings with possible metadata
    - Object: {["Property"] = {param = "param_name"}}
                      Format can be:
    - Complex: {["Property"] = {mappings = [{param="p1", metadata={...}}, ...]}}
                      1. Simple: {["Property"] = "param_name"}
    - Subobject: {["Property"] = {is_subobject=true, properties={...}, id_prefix="..."}}
                      2. Object: {["Property"] = {param = "param_name"}}
  @param options - Configuration options
                      3. Complex: {["Property"] = {mappings = {{param = "p1", metadata = {...}}, ...}}}
  @return Generated markup or empty string if using native API
                      4. Subobject: {["Property"] = {is_subobject = true, properties = {property map}, id_prefix = "optional_prefix"}}
    @param options - Configuration options (same as generateAnnotations)
   
    @return Empty string if set via mw.smw, or generated annotations string
]]
]]
function p.setSemanticProperties(args, mappings, options)
function p.setSemanticProperties(args, mappings, options)
     -- Check if mw.smw is available
     -- Fall back to parser functions if mw.smw unavailable
     if not mw.smw then
     if not mw.smw then return p.generateEnhancedAnnotations(args, mappings, options) end
        -- Fall back to enhanced parser function approach
        return p.generateEnhancedAnnotations(args, mappings, options)
    end
      
      
     options = options or {}
     options = options or {}
Line 384: Line 273:
     local default = options.default or {}
     local default = options.default or {}
     local prefix = options.prefix or ""
     local prefix = options.prefix or ""
   
    -- Build the property table for mw.smw.set
     local properties = {}
     local properties = {}
     local semanticOutput = ""
     local semanticOutput = ""
      
      
     -- Process all mappings
     -- Process all mapping types
     for property, mapping in pairs(mappings) do
     for property, mapping in pairs(mappings) do
         local fullPropertyName = prefix .. property
         local fullPropertyName = prefix .. property
          
          
        -- Determine the type of mapping
         if type(mapping) == "string" then
         if type(mapping) == "string" then
             -- Legacy simple string mapping
             -- Simple string mapping
             processSimpleMapping(properties, fullPropertyName, args[mapping], transform[property], default[property])
             processSimpleMapping(properties, fullPropertyName, args[mapping], transform[property], default[property])
         elseif type(mapping) == "table" then
         elseif type(mapping) == "table" then
             if mapping.is_subobject then
             if mapping.is_subobject then
                 -- This is a special subobject definition
                 -- Subobject definition
               
                -- Get the subobject properties map
                 local subobjectProperties = mapping.properties or {}
                 local subobjectProperties = mapping.properties or {}
               
                -- Create the actual properties map by processing each property value
                 local actualProperties = {}
                 local actualProperties = {}
                  
                  
                 -- Process each property definition in the subobject
                 -- Process subobject properties
                 for subPropName, subPropValue in pairs(subobjectProperties) do
                 for subPropName, subPropValue in pairs(subobjectProperties) do
                     if type(subPropValue) == "table" and subPropValue.param then
                     if type(subPropValue) == "table" and subPropValue.param then
                         -- Object with param reference
                         -- Object with param reference
                         local paramName = subPropValue.param
                         local paramName = subPropValue.param
                       
                        -- Get the value from args
                         if args[paramName] and args[paramName] ~= "" then
                         if args[paramName] and args[paramName] ~= "" then
                             local value = args[paramName]
                             local value = args[paramName]
                           
                            -- Apply transform if one exists for this property
                             if subPropValue.transform and type(subPropValue.transform) == "function" then
                             if subPropValue.transform and type(subPropValue.transform) == "function" then
                                 value = subPropValue.transform(value)
                                 value = subPropValue.transform(value)
                             end
                             end
                           
                            -- Set the property
                             actualProperties[subPropName] = value
                             actualProperties[subPropName] = value
                         end
                         end
                     elseif type(subPropValue) == "string" then
                     elseif type(subPropValue) == "string" then
                         -- Simple string mapping or static value
                         -- String mapping or static value
                         if args[subPropValue] and args[subPropValue] ~= "" then
                         if args[subPropValue] and args[subPropValue] ~= "" then
                            -- It's a parameter reference
                             actualProperties[subPropName] = args[subPropValue]
                             actualProperties[subPropName] = args[subPropValue]
                         else
                         else
                            -- It's a static value
                             actualProperties[subPropName] = subPropValue
                             actualProperties[subPropName] = subPropValue
                         end
                         end
Line 437: Line 311:
                 end
                 end
                  
                  
                 -- If we have at least one property to set
                 -- Create subobject if properties exist
                 if next(actualProperties) then
                 if next(actualProperties) then
                     -- Generate a reasonably unique ID for the subobject
                     -- Generate ID
                     local idPrefix = mapping.id_prefix or "subobj"
                     local idPrefix = mapping.id_prefix or "subobj"
                     local idValue = ""
                     local idValue = ""
                    local primaryProp = mapping.primary_property
                      
                      
                    -- Try to use primary property value as part of the ID
                    local primaryProp = mapping.primary_property
                     if primaryProp and actualProperties[primaryProp] then
                     if primaryProp and actualProperties[primaryProp] then
                        -- Clean the value to use in an ID
                         idValue = tostring(actualProperties[primaryProp]):gsub("[^%w]", "_")
                         idValue = tostring(actualProperties[primaryProp]):gsub("[^%w]", "_")
                     else
                     else
                        -- Just use an incremental number if no primary property
                         idValue = tostring(os.time() % 10000) .. "_" .. math.random(1000, 9999)
                         idValue = tostring(os.time() % 10000) .. "_" .. math.random(1000, 9999)
                     end
                     end
                      
                      
                    -- Create the full ID
                     local subobjectId = idPrefix .. "_" .. idValue
                     local subobjectId = idPrefix .. "_" .. idValue
                      
                      
                     -- Create the subobject
                     -- Create subobject
                     if mw.smw then
                     local subobjectResult = mw.smw.subobject({
                        -- Use native SMW API
                        id = subobjectId,
                        local subobjectResult = mw.smw.subobject({
                        properties = actualProperties
                            id = subobjectId,       -- Use our generated ID
                    })
                            properties = actualProperties
                   
                        })
                    -- Add error info if needed
                       
                    if type(subobjectResult) == "table" and subobjectResult.error then
                        -- If there was an error, append it to output for debugging
                        semanticOutput = semanticOutput .. "\n<!-- SMW Error: " ..  
                        if type(subobjectResult) == "table" and subobjectResult.error then
                                        tostring(subobjectResult.error) .. " -->"
                            semanticOutput = semanticOutput .. "\n<!-- SMW Subobject Error: " ..  
                                            tostring(subobjectResult.error) .. " -->"
                        end
                    else
                        -- Parser function fallback
                        semanticOutput = semanticOutput .. "\n" ..
                                        generateSmwSubobjectFragment(actualProperties, subobjectId)
                     end
                     end
                 end
                 end
Line 485: Line 348:
     end
     end
      
      
     -- Only set properties if we have some
     -- Set properties if any exist
     if next(properties) then
     if next(properties) then
        -- Set the properties using the native SMW interface
         local success, result = pcall(function() return mw.smw.set(properties) end)
         local success, result = pcall(function()
         if success then return semanticOutput
            return mw.smw.set(properties)
         else return p.generateEnhancedAnnotations(args, mappings, options) .. semanticOutput
        end)
       
        -- If successful, return semanticOutput (which might contain subobject results)
        -- If failed, fall back to parser function approach
         if success then
            return semanticOutput
         else
            return p.generateEnhancedAnnotations(args, mappings, options) .. semanticOutput
         end
         end
     end
     end
Line 504: Line 359:
end
end


-- Helper function to generate #subobject parser function with an ID
-- Generate #subobject parser function with optional ID
function p.generateSmwSubobjectFragment(properties, id)
function p.generateSmwSubobjectFragment(properties, id)
     local result = '<div style="display:none;">\n  {{#subobject:'
     local result = '<div style="display:none;">\n  {{#subobject:'
   
     if id and id ~= "" then result = result .. "|@" .. id end
    -- Set the ID if available
     if id and id ~= "" then
        result = result .. "|@" .. id
    end
      
      
     for propName, propValue in pairs(properties) do
     for propName, propValue in pairs(properties) do
Line 523: Line 374:
end
end


-- For backward compatibility with local reference
-- For backward compatibility
generateSmwSubobjectFragment = p.generateSmwSubobjectFragment
generateSmwSubobjectFragment = p.generateSmwSubobjectFragment


return p
return p