Template:Tlg/doc
This is a documentation subpage for
Template documentation[edit source]Template:Terminate sentence ensures a sentence ends with a specified terminator (default: a period). It avoids adding duplicate terminators and can optionally trim trailing spaces. It attempts to ignore trailing closing quotes or brackets when deciding whether a terminator is already present. Usage[edit source]Basic: {{Terminate sentence|This is a sentence}}
→ This is a sentence.
Named parameters: {{Terminate sentence
|text=He said "Hello"
|term=.
}}
→ He said "Hello".
Custom terminator: {{Terminate sentence|text=Warning|term=!}}
→ Warning!
Avoid duplicate terminator: {{Terminate sentence|text=Already done.|term=.}}
→ Already done.
Trim trailing spaces: {{Terminate sentence|text=Ends with space |trim=yes}}
→ Ends with space.
Skip processing: {{Terminate sentence|text=No changes here|skip=yes}}
→ No changes here
Append a note: {{Terminate sentence|text=Complete|note=(source: 2025)}}
→ Complete. (source: 2025)
Parameters[edit source]
Behavior details[edit source]
Examples[edit source]
{{Terminate sentence|text=He whispered "hush"|term=.}}
→ He whispered "hush".
{{Terminate sentence|text=Complete (verified)|term=.}}
→ Complete (verified).
{{Terminate sentence|text=Alert|term=!}}
→ Alert!
{{Terminate sentence|text=Wait...|term=.|allowdup=yes}}
→ Wait.... Best practices[edit source]
Lua-powered variant (optional)[edit source]For more robust detection (including multilingual quotes and punctuation), create -- Module:TerminateUtil
local M = {}
local closing = {
[")"] = true, ["]"] = true, ["}"] = true,
['"'] = true, ["'"] = true, ["”"] = true, ["’"] = true, ["»"] = true, ["›"] = true
}
local function trimRight(s)
return (s:gsub("%s+$",""))
end
function M.lastVisibleChar(args)
local s = args.s or ""
s = trimRight(s)
local i = #s
while i > 0 do
local c = s:sub(i,i)
if closing[c] then
i = i - 1
else
return c
end
end
return ""
end
return M
Then update the template to call: {{#invoke:TerminateUtil|lastVisibleChar|s=text}}
This improves detection for closing quotes and brackets. See also[edit source]It may contain usage information, categories and other content that is not part of the original template page. |
Explanation
[edit source]{{tlg}} (template link, general) is a general template for inserting a template link. It can be used to replace or implement any of the more specific {{tl*}} templates, e.g. {{tl}}, {{tlx}} or {{tlb}}. Parameters are:
bold=yes: Boldface the text, like for{{tlb}}and{{tlxb}}italic=yes: Italicizes the parameters, like for{{tlxi}}tt=yes: Use a monospaced font, like for{{tlx}}and{{tlxb}}code=yes: Use the<code>...</code>HTML attribute (usually a monospaced font), like for{{tlc}}nolink=yes: Don't insert a template link, like for{{tlf}},{{tld}}, and{{tlc}}anypage=yes: Allow linking to arbitrary page (not just template), as with{{tlu}}braceinside=yes: Put braces inside the link, like for{{tn}}subst=yes: Add asubst:prefix, like for{{tls}}alttext=FOO: Specify alternative surface text for a link, like for{{tla}}
Examples
[edit source]| Code | Result | Remark |
|---|---|---|
{{Tlg|Abc}} |
{{Abc}} | |
{{Tlg|ABC}} |
{{ABC}} | |
{{Tlg|AbC}} |
{{AbC}} | |
{{Tlg|x0}} |
{{x0}} | |
{{Tlg|x0|bold=yes}} |
{{x0}} | |
{{Tlg|x1|one|italic=yes}} |
{{x1|one}} | |
{{Tlg|x0|code=yes}} |
{{x0}} |
|
{{Tlg|x0|tt=yes}} |
{{x0}} | |
{{Tlg|x0|nolink=yes}} |
{{x0}} | |
{{Tlg|x0|subst=yes}} |
{{subst:x0}} | |
{{Tlg|x0|braceinside=yes}} |
{{x0}} | |
{{Tlg|x0|alttext=Link to x0 template}} |
{{Link to x0 template}} | |
{{Tlg|x0|anypage=yes}} |
{{x0}} | Now the expression links to x0 (the spaceship, genetic disease, etc.) rather than Template:x0. Mostly useful for templates in user space. |
{{Tlg|x0|bold=yes|tt=yes|braceinside=yes}} |
{{x0}} | No reason you can't combine multiple parameter settings. |
{{Tlg|x1|one}} |
{{x1|one}} | |
{{Tlg|x2|one|two}} |
{{x2|one|two}} | |
{{Tlg|x2|bold=yes|tt=yes|one|two}} |
{{x2|one|two}} | Can combine named and anonymous parameters ... |
{{Tlg|x2|one|two|bold=yes|tt=yes}} |
{{x2|one|two}} | ... in any order … |
{{Tlg|x2|one|tt=yes|two|bold=yes|three}} |
{{x2|one|two|three}} | ... even intermixed ... |
{{Tlg|x2|one|tt=yes|two|bold=yes|three|italic=yes}} |
{{x2|one|two|three}} | ... with many different configurations. |
{{Tlg|x3|1|2|3|4|5|6|7|8|9|10}} |
{{x3|1|2|3|4|5|6|7|8|9|10}} | |
{{Tlg|x4|1|2|3|4|5|6|7|8|9|10|11}} |
{{x4|1|2|3|4|5|6|7|8|9|10|...}} | up to 10 parameters, then ... |
{{Tlg|x5|1|2|3|4|5|6|7|8|9|10|11}} |
{{x5|1|2|3|4|5|6|7|8|9|10|11}} | | for more |
{{Tlg|convert|<nowiki>14|m|ftin|abbr=out|sp=us</nowiki>}} |
unlimited parameters as one nowiki string | |
{{Tlg}} |
{{Tlg/doc}} | with no arguments, the current page name is substituted |
{{Tlg|x1|x=u}} |
{{x1}} | = won't work |
{{Tlg|x1|x=u}} |
{{x1|x=u}} | = is okay |
{{Tlg|x1|x{{=}}u}} |
{{x1|x=u}} | {{=}} is okay |
{{Tlg|x1|<nowiki>x=u</nowiki>}} |
{{x1|x=u}} | sticky nowiki is okay |
{{Tlg|x2| |two}} |
{{x2|two}} | empty won't work |
{{Tlg|x2| |two}} |
{{x2| |two}} |   is okay |
{{Tlg|x2| |two}} |
{{x2| |two}} | is okay |
{{Tlg|x2| | two}} |
{{x2| | two}} | | is okay |
{{Tlg|x2| {{!}} two}} |
{{x2| | two}} | {{!}} is dubious |
{{Tlg|x2|2=|3=two}} |
{{x2|two}} | empty really doesn't work |
{{Tlg|x2|2=one|two}} |
{{x2|two}} | two clobbers 2=one |
{{Tlg|x2|3=two|2=one}} |
{{x2|one|two}} | right to left okay |