Module:TemplateHelpers: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 1: Line 1:
-- Module:TemplateHelpers
-- Module:TemplateHelpers
-- Common helper functions for template modules to promote code reuse and consistency. This module provides utilities for string processing, field handling, normalization, and standardized block rendering to be used across multiple template types.
-- Common helper functions for template modules promoting code reuse and consistency.
-- Provides utilities for string processing, field handling, normalization, and block rendering.


local p = {}
local p = {}
Line 508: Line 509:


-- Generates semantic properties based on configuration
-- Generates semantic properties based on configuration
-- @param args - Template parameters table
-- @param args - Template parameters
-- @param semanticConfig - Configuration table with properties, transforms, and additionalProperties
-- @param semanticConfig - Config with properties, transforms, additionalProperties
-- @param options - Options table with the following possible keys:
-- @param options - Options: transform (functions), skipProperties (to exclude)
--  - transform: Table of transformation functions for properties
-- @return Wikitext with semantic annotations
--  - skipProperties: Table of properties to skip in processAdditionalProperties
-- @return Wikitext string containing semantic annotations
function p.generateSemanticProperties(args, semanticConfig, options)
function p.generateSemanticProperties(args, semanticConfig, options)
     if not args or not semanticConfig then return "" end
     if not args or not semanticConfig then return "" end
Line 544: Line 543:


-- Creates a standardized configuration structure for template modules
-- Creates a standardized configuration structure for template modules
-- This ensures all templates have a consistent configuration format
function p.createStandardConfig(config)
function p.createStandardConfig(config)
     config = config or {}
     config = config or {}