Module

Underscore to Space

From Halal Explorer

Documentation for this module may be created at Module:Underscore to Space/doc

Script error: Lua error: Cannot create process: proc_open(/dev/null): Failed to open stream: Operation not permitted

local str = {}

function str._getParameters( frame_args, arg_list )
    local new_args = {};
    local index = 1;
    local value;
    
    for i,arg in ipairs( arg_list ) do
        value = frame_args[arg]
        if value == nil then
            value = frame_args[index];
            index = index + 1;
        end
        new_args[arg] = value;
    end
    
    return new_args;
end

function str.replace( frame )
    local result;
    local new_args = str._getParameters( frame.args, {'source'} ); 
    local source_str = new_args['source'] or '';
        
    if source_str == '' then
        return source_str;
    end    

    result = mw.ustring.gsub( source_str, '_', ' ' );

    return result;
end

return str