FANDOM


Sometimes I run into the same problem over and over... I need to take a step back and remember what I've learned in the past.

Page Layout Troubleshooting

My image bleeds into the next section

You are using a floated image with thumb, left, or right defined as an argument. This causes the image to "float" which means all other content will wrap around it. In order to force a break after the floating image, you need to call the Clear template like so.

{{Clear}}

Here is an example of forcing the next section to appear below the thumbnail instead of right beside it.

Kareiishi

The text appears on only one line after my image

KareiishiYour image is *not* floated, so the image will appear only on one line of text until a line break happens. See paragraph as an example. The solution is to either float the image (likely using left) or to screw around with a layout table.

Kareiishi This is an example of a layout table. View the source code of this blog post to see what I mean. A layout table is a table whose only purpose is to control the appearance of the content. As a result, you should avoid adding descriptional code to the table such as captions and table column headers. This will cause people and machines to believe your table controls content and data flow rather than presentation. Read up about accessibility and screen readers to learn more.

Lua Module Troubleshooting

How do templates and modules interact?

A template will call a Lua module. The template call on a page may look like this.

{{SampleTemplate|arg1}}

The template, named Template:SamepleTemplate, simply calls the Lua module. The template's contents look like this.

{{#invoke:ExampleModule|testFunction}}

The module, named Module:ExampleModule, needs some boilerplate code before it gets to work. The module's contents look like this.

local p = {}
local get_args = require('Module:Arguments').getArgs

function p.testFunction(frame)
    local args = get_args(frame:getParent())
    return p._testFunction(args)
end

function p._testFunction(args)
    local arg1 = args[1]
    if not arg1 then
        arg1 = 'unset'
    end
    return 'Argument 1 was ' .. arg1
end

return p

No args being passed to the Lua module

First, don't forget the template -> module calling hierarchy. If you attempt to directly invoke the module, the frame:getParent() code will get in the way and make Module:Arguments look in the wrong place for the arguments. All of your arguments will disappear.

Secondly, don't forget that positional arguments start at array index one instead of zero. This is a single positional argument on a page's call to a template.

{{SampleTemplate|arg1}}

Access this in the Lua code like so.

args[1]

Thirdly, named arguments are accessed by name. This is a single named argument on a page's call to a template.

{{SampleTemplate|fun=arg1}}

Access this in the Lua code like so.

args["fun"]

My number-based arguments are not working correctly

All arguments sent to templates and modules are strings irregardless of whether they can be numbers or not. Use Lua's tonumber(arg) function to type-cast the args.

Changes to my Template/Module are not affecting pages that use them

After editing a template or module, changes will not propagate to the pages that access them for awhile because it has to re-process the pages. If you want to force the page to update, either 'purge' the page or use the following trick. Edit the page and then save the page without changing the contents or the commit summary.