Home
Random
Log in
Settings
About The Republic Wiki
Disclaimers
The Republic Wiki
Search
Editing
Template talk:If preview
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{Permanently protected}} == Merge with Ifpreview == {{ping|Evad37}} Should [[Template:Ifpreview]] be merged into this? They do the exact same thing, although {{tl|Ifpreview}} allows named arguments. That said, it's essentially unused, so maybe backwards compatibility doesn't matter. [[User:Daask|Daask]] ([[User talk:Daask|talk]]) 07:28, 28 March 2018 (UTC) == Preview warning and hatnotes moving to templatestyles == Page watchers may be interested in {{slink|MediaWiki talk:Common.css|Preview warning and hatnotes moving to TemplateStyles}} [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 23:57, 28 April 2021 (UTC) == Fix documentation please == {{resolved}} */doc now says: "use the <code>main()</code>". Which is incorrect (should be: <code>main</code>). : And: "use the <code>_warning()</code>". Which is incorrect (should be: <code>_warning</code>). *<s>Also, there is no overview of parameters to be used. (how do I enter the _warning_text?)</s>. :-[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 18:57, 20 June 2021 (UTC) ::resolved: this pertains to the Module documentation, not this template. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 07:53, 22 June 2021 (UTC) == Use in module == '''Re: [[Module:If preview]]''' I tried to use _warning() in [[Module:Authority control/sandbox]] but the warning is displayed in-situ and not at the top of the page where it should be. Am I doing something wrong? — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 16:34, 30 December 2022 (UTC) :@[[User:Izno|Izno]] can you advise on this please - did it used to work or am just misremembering something? — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 10:59, 19 July 2023 (UTC) ::_warning has always been placed at the location where the warning would normally be emitted. If you want it to appear at the top of the article only, [[mw:Extension:Scribunto/Lua_reference_manual#mw.addWarning|mw.addWarning]] is the only function that does that. You may otherwise be confused here because outputs of _warning are most common due to infoboxes, which are always at the top of the page. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 16:14, 19 July 2023 (UTC) :::Quite possible that I am misremembering! Did you consider using mw.addWarning rather than the REVISIONID hack? — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 16:57, 19 July 2023 (UTC) ::::REVISIONID is the supported way to check for preview and is how both this system's warning and ifpreview worked before I touched it. ::::Besides that, because mw.addWarning appears in a different place than in situ, and I know that people have been sensitive on the point before, that would be a consensus-needed to change. ::::Identical messages are also de-duplicated somewhere in addWarning's call stack. I don't know how relevant that is generally. See [[Help_talk:Citation_Style_1/Archive_77#summary_messaging_in_the_preview_warning_header|some previous discussion for CS1]]. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 17:16, 19 July 2023 (UTC) :::::Useful, thanks. It seems that addWarning does not work with the live preview, which is a serious limitation — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 17:43, 19 July 2023 (UTC) ::::::Yes, I suppose that's true. It might be worth a task to see if it's even feasible to act on that. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 18:42, 19 July 2023 (UTC) == Template-protected edit request on 28 March 2024 == {{edit template-protected|Module:If preview|answered=yes}} In the function <code><nowiki>p._warning</nowiki></code> please add before the return call: <code><nowiki>mw.addWarning(warning)</nowiki></code>. This will put the preview warning at the top of the preview in addition to inline in the wikitext. [[User:Awesome Aasim|Awesome]] [[User_talk:Awesome Aasim|Aasim]] 23:29, 28 March 2024 (UTC) :<s><nowiki>{{Done}}</nowiki></s>. [[User:SilverLocust|<small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust</small>]] [[User talk:SilverLocust|💬]] 19:54, 31 March 2024 (UTC) ::{{Reply|Awesome Aasim}} The [[Special:Diff/1216624147|edit has been reverted]] because it resulted in [[Module:Parameter validation/default config]] emitting erroneous preview warnings. Templates like [[Template:Marriage]] and any others with <syntaxhighlight lang="wikitext" inline>{{#invoke:Parameter validation|validateparams|module_options = Module:Parameter validation/default config}}</syntaxhighlight> would always give the incorrect preview warnings: ::{{tqb|Script warning: [[templatename]] used with unknown parameter(s): paramname. <br>Script warning: [[templatename]] used with deprecated parameter(s): paramname. <br>Script warning: [[templatename]] used with duplicate parameter(s): paramandvalue.}} ::(You can see the erroneous preview warnings with the example in the below quote box. Preview an edit of this section to see the warnings.) {{quotebox|{{marriage/sandbox|Example|2020}}}} ::Apparently the [[Module:Parameter_validation/default_config#L-11|options in the (default) config]] are evaluated when the <code>options</code> table is intially loaded in as a variable (i.e., before those options are actually needed, and even if they will not be needed), since those function calls aren't stored unevaluated in the table (e.g., as a string or sub-table). And evaluating those first three options involves calling <code>_warning</code> and thus (until the edit was reverted) calling <code>mw.addWarning</code>. ::That being said, I am not presently sure how this should be fixed. [[User:SilverLocust|<small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust</small>]] [[User talk:SilverLocust|💬]] 06:00, 1 April 2024 (UTC) (and subsequently edited) :::Additionally, in looking now at the section above this, there is a [[#c-MSGJ-20230719165700-Izno-20230719161400|comment]] that <code>mw.addWarning</code> should not be added here without consensus due to some previous sensitivity. (Part of why I thought this wouldn't be controversial was because [[Template:Preview warning/doc]] already said — erroneously — that the warning always appears at the top, and because it seemed self-evident that a "preview warning" should use MediaWiki's built-in preview warning function, <code>mw.addWarning</code>.) [[User:SilverLocust|<small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust</small>]] [[User talk:SilverLocust|💬]] 08:32, 1 April 2024 (UTC) (and subsequently edited) ::::That sounds like bad code to me. The only other thing I can think of is maybe a module that when preprocessed emits the preview warning. A warning should not be emitted if there is a code problem, so calling the function beforehand creates a ton of headaches. If the config needs to fetch the default text for preview warnings it should be calling a getter to get the message not a function that builds the warning. [[User:Awesome Aasim|Awesome]] [[User_talk:Awesome Aasim|Aasim]] 08:41, 1 April 2024 (UTC) == Template-protected edit request on 29 August 2024 == {{edit template-protected|Module:If preview|answered=yes}} Please implement my changes in the [[Module:If preview/sandbox|sandbox]]. I addressed some of the concerns above, and added a new function <code>warn</code> that calls both mw.addWarning and adds the warning to the preview, as well as <code>consoleWarning</code>. I also added [[Module:Arguments]] for better argument processing, and added a parameter "consolewarning" that would emit a warning in the "script warning" section of the edit window where it is desired. This should ensure backwards compatibility. [[User:Awesome Aasim|Awesome]] [[User_talk:Awesome Aasim|Aasim]] 18:17, 29 August 2024 (UTC) :Yes please! If using mw.addWarning() is for some reason controversial, the obvious solution is to do that via a separate function (or, I guess, an argument to an existing one). Flipping the default (making mw.addPreview() opt-out would make more sense, but seems more effort than it's worth. on enWP; on enWS where I import it I'd swap it in a heartbeat if I could without creating merge issues for myself). [[User:Xover|Xover]] ([[User talk:Xover|talk]]) 10:49, 1 September 2024 (UTC) :{{done}}<!-- Template:ETp --> — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 19:58, 9 September 2024 (UTC) == Edit request 15 July 2025 == {{Edit template-protected|Module:If preview/styles.css|answered=yes}} '''Description of suggested change:''' Add support for dark mode. '''Diff:''' (in [[Module:If preview/styles.css#L-7]] {{TextDiff|1= color: red;|2= color: var(--color-error, red);}} [[User:Dabao qian|Dabao qian]] ([[User talk:Dabao qian|talk]]) 06:31, 15 July 2025 (UTC) : {{Done}} [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 22:29, 16 July 2025 (UTC)
Summary:
Please note that all contributions to The Republic Wiki are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see
The Republic Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Done
(
edit
)
Template:Edit template-protected
(
edit
)
Template:Permanently protected
(
edit
)
Template:Ping
(
edit
)
Template:Quotebox
(
edit
)
Template:Reply
(
edit
)
Template:Resolved
(
edit
)
Template:Section link
(
edit
)
Template:Slink
(
edit
)
Template:Template link
(
edit
)
Template:TextDiff
(
edit
)
Template:Tl
(
edit
)
Template:Tqb
(
edit
)
Module:Arguments
(
edit
)
Module:Section link
(
edit
)
Module:Yesno
(
edit
)
Return to "If preview" page.