Шаблон:Docpage: различия между версиями
(исправил ранее незамеченную ошибку) |
(по причине кривой установки MediaWiki остаётся указывать название шаблона явным образом; категорию лучше указывать в документации) |
||
Строка 1: | Строка 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
--><div class="plainlinks" style="background-color: #F9F9F9; border: 1px solid #DBDBDB; border-radius: 10px; padding: 5px; font-size: 95%; margin: auto auto 0.5em; text-align: center; white-space: nowrap"><!-- | --><div class="plainlinks" style="background-color: #F9F9F9; border: 1px solid #DBDBDB; border-radius: 10px; padding: 5px; font-size: 95%; margin: auto auto 0.5em; text-align: center; white-space: nowrap"><!-- | ||
-->[[Шаблон:{{ | -->[[Шаблон:{{{1}}}]]<sup>[{{fullurl:Шаблон:{{{1}}}|action=edit}} e] [{{fullurl:Шаблон:{{{1}}}|action=purge}} p] [{{fullurl:Шаблон:{{{1}}}|action=history}} h]</sup> <!-- | ||
--><span style="margin:0 2em">[[ | --><span style="margin:0 2em">[[{{FULLPAGENAME}}|Документация]]</span> <!-- | ||
--><span style="margin-right:2em">[[Обсуждение шаблона:{{ | --><span style="margin-right:2em">[[Обсуждение шаблона:{{{1}}}|Обсуждение]]</span> <!-- | ||
-->[[Служебная:Whatlinkshere/{{ | -->[[Служебная:Whatlinkshere/{{{1}}}|Где используется]]</div></includeonly><noinclude>{{doc}}</noinclude> | ||
Версия 04:30, 22 ноября 2020
<templatestyles src="Шаблон:Doc/styles.css" />
local yesno = require('Module:Yesno') local compressSparseArray = require('Module:TableTools').compressSparseArray local p = {}
local function unpack(...) local frame = ... local args if type(frame.args) == 'table' then args = getArgs(frame) elseif type(frame) == 'table' then args = frame else args = {...} end return args end
function p._main(anchor, text, visible) local result = mw.html.create('span') :attr('id', anchor) :wikitext(text) if visible then result:addClass('highlight-target') end return tostring(result) end
function p.main(...) local args = unpack(...) local anchors = compressSparseArray(args) local text local visible = yesno(args.visible or args.v) if visible then text = args.text or args['текст'] or args[1] end
local result = text for i, v in ipairs(anchors) do result = p._main(anchors[i], result, visible) --[[ создание старого вида якорей для совместимости, см. Обсуждение шаблона:Якорь#Новые html5 ссылки и старые ]] local encoded_anchor = mw.uri.encode(anchors[i], 'WIKI'):gsub('%%', '.') if anchors[i] ~= encoded_anchor then result = p._main(encoded_anchor, result, visible) end end
return result end
return p{{#if: | {{#ifexist: {{{1}}}
| {{{{{1}}}||||}} | {{#ifexist: Шаблон:{{{1}}} | {{{{{1}}}||||}} | Шаблон:Документировать }} }}
| {{#ifexist: Шаблон:Docpage/doc
| Шаблон:Docpage/doc | Шаблон:Документировать }}
}}
<templatestyles src="Шаблон:Doc/styles.css" />{{#ifexpr: 10 mod 2 = 1
| A test for all to see
|
}}