Content deleted Content added
→The following seemed too off-topic for the CFD discussion: how it might be done |
Cobaltcigs (talk | contribs) ok |
||
Line 49:
::::: Modules indeed can't read the rendered html as they run on the server before the displayed text is generated. Modules can use the <code><nowiki>mw.title.getCurrentTitle():getContent()</nowiki></code> method to read the current page's unparsed content, and finding the templates is trivial, but you won't be able to compare the contents unless you use <code><nowiki>mw.getCurrentFrame():expandTemplate{}</nowiki></code> to explicitly expand the generated template or require [[Module:Settlement short description]] and call it. Frankly, I wouldn't bother.
::::: The manually entered {{tl|short description}} and the one generated from {{tl|infobox settlement}} are styled in identical spans because they are functionally identical (and because the generated one actually calls [[Template:short description]]). You don't need to confirm which one takes precedence because you already know that the one which is manually entered has precedence because of <code>noreplace</code> being added in the generator{{snd}} see [[Module:Settlement short description]] line 30. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 18:06, 4 October 2020 (UTC)
{{unindent}} Okay so some amount of research later, I've come to realize this "noreplace" parameter is actually passed along as the second parameter to a certain <code><nowiki>{{SHORTDESC:...|...}}</nowiki></code> "magic word"—and that this mechanism is totally separate from the hidden(-by-default) span tag, which only uses the first parameter. Fair enough. I suppose I was preoccupied with the span tag because I use client-side css like this to make the description (or potentially multiple descriptions) clearly visible:
<source lang="css">
.shortdescription { display: block !important; color: red; white-space: pre-wrap; font-family: monospace; font-size: larger; width: auto; border-bottom: 1px dashed black; }
.shortdescription::before { content: "{{short description|"; color: black; }
.shortdescription::after { content: "}}"; color: black; }
</source>
As designed I don't see any robust way to identify and unhide only the description that, based on whatever internal noreplace-logic, is ultimately used. Perhaps the name <code>noreplace</code> could be appended to the span's list of classes, when applicable. Then one could at least use javascript to examine the spans' classes and decide by elimination which one to unhide. ―[[special:contributions/cobaltcigs|cobaltcigs]] 19:50, 4 October 2020 (UTC)
|