Toggle menu
30
52
1
249
OneSkyVed's Trolleybuses Place Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
TrP Tools logo Groups Shifts Tools Dashboard Wiki

Module:ArticleButton: Difference between revisions

From OneSkyVed's Trolleybuses Place Wiki
No edit summary
No edit summary
 
Line 7: Line 7:
     local image = args.image
     local image = args.image
      
      
     if string.len(label) >= 34 then
     if string.len(label) >= 32 then
     label = string.sub(label, 1, 33).."..."
     label = string.sub(label, 1, 31).."..."
     end
     end



Latest revision as of 22:32, 16 December 2024

Documentation for this module may be created at Module:ArticleButton/doc

local p = {}

function p.render(frame)
    local args = frame:getParent().args
    local article = args.article or mw.title.getCurrentTitle().fullText
    local label = args.label or mw.title.new(article).text
    local image = args.image
    
    if string.len(label) >= 32 then
    		label = string.sub(label, 1, 31).."..."
    end

    local html = mw.html.create("span")
    html:addClass("button-with-circle")
        :tag("div")
            :addClass("circle-image")
            :wikitext( string.format( '[[File:%s|x48px|link=]]', image ) )
        :done()
        :tag("span")
            :wikitext(string.format('[[%s|%s]]', article, label))
        :done()

    return tostring(html)
end

return p