I get this error:
| Module:Unsubst is indefinitely protected from editing as it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit protected}} to notify an administrator to make the requested edit.
|
This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
I get this error:
Lua error in Module:Unsubst at line 18: attempt to call field 'isSubsting' (a nil value).
Shouldn't that be isSubstring? ☠MarkAHershberger☢(talk)☣ 16:27, 25 November 2013 (UTC)
|$N=You can get the template name from mw.getCurrentFrame():getTitle() — Keφr 08:59, 27 March 2014 (UTC)
mw.getCurrentFrame():getParent():getTitle(), and it does work. (And above, I actually meant mw.getCurrentFrame().parent:getTitle(), which does not.) — Keφr 09:50, 27 March 2014 (UTC)
{{#invoke:Unsubst|unsubst}}, when actually it's just {{#invoke:Unsubst|}}. As for the expensive mw.title.new, I agree that if it only gets called on subst then it shouldn't be a problem. — Mr. Stradivarius ♪ talk ♪ 12:20, 27 March 2014 (UTC)
I have a local wikipedia copy and get the 'Lua error in Module:Unsubst atline 18: attempt to call field 'isSubsting' (a nill value)' error and I have changed the Unsubst module to the new one but still get the error, is there anything else I need to do?
$N (template name) parameter in the #invoke text, whereas in the latest version this is not necessary. — Mr. Stradivarius ♪ talk ♪ 12:25, 22 April 2014 (UTC)
This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Please make these changes. Jackmcbarn (talk) 15:04, 22 August 2014 (UTC)
Using this module imposes a time penalty. Not surprising, that. I have been experimenting with a module to translate {{Literatur}} (a template that attempts to translate de.wiki's Vorlage:Literatur to a {{citation}} template). In its current form, {{Literatur}} is always subst'd so I tweaked {{citation/new}} (the sandbox) to use this module. At Help talk:Citation Style 1 § non-English translator templates and substing I was queried about the time penalty. My simple experiments show that there is a significant time penalty for no benefit.
In that discussion, I wondered if the translator module might call a special substable version of {{citation}} so I created {{citation/subst}} which uses this module and then modified the translator module to call that template. The substitution worked as it should except that the substituted template name was {{citation/subst}}. In that discussion at WT:CS1, I also wondered if this module might be tweaked to support a template invocation name override parameter. I have tweaked the sandbox to support |$template-name=. {{citation/subst}} uses this parameter to set the template name to citation/new and when a {{Literatur/sandbox}} template is subst'd, the result is an invocation of {{citation/new}}.
If there are no objections, I will update the live module from the sandbox. Comments, of course, are welcome.
—Trappist the monk (talk) 18:06, 20 August 2021 (UTC)
I'm looking to add a signature option to {{Dashboard.wikiedu.org assignment}} using this template so that if someone adds the template, a bot can subst the call and return the original template call plus the user's signature (or maybe even just a timestamp). However, I am concerned that adding in something dynamic like a timestamp will cause issues if the template is substed. Basically, I'm not sure how to code it so that it gives accurate information that stays static after substing. Example:
{{dashboard.wikiedu.org assignment | course = Wikipedia:Example | assignments = [[User:Primefac]] | start_date = 2022-01-24 | end_date = 2022-05-13 }}Substing the template call would ideally give something like
This is primarily to allow for archiving when the course is over (because at current, sections like this won't ever be archived). Please let me know how far off the mark I am. Thanks! Primefac (talk) 08:17, 16 March 2022 (UTC)
__DATE__ that is replaced with the current month and year when adding the parameter while substing. This is used in maintenance templates. Anomie⚔ 11:44, 16 March 2022 (UTC)
When I read the documentation I incorrectly assumed that the square brackets were a required part of the syntax, i.e. |$aliases=[œuf>egg,melt>cheese] but actually it should be |$aliases=œuf>egg,melt>cheese Perhaps the wording can be made clearer? — Martin (MSGJ · talk) 11:53, 17 July 2024 (UTC)
A common way this module is used with wrapper templates which are supposed to be replaced, e.g.
{{SAFESUBST:<noinclude />#invoke:Unsubst|main
|Senegal=yes|subst=
|$template-name=WikiProject Africa
|$flags=override,remove-empty
|$aliases=importance>Senegal-importance
|$B={{WikiProject Africa
|class={{{class|}}}
|Senegal=yes
|Senegal-importance={{{importance|}}}
|category={{{category|}}}
}}
}}
It seems to me there could be a simpler way to do this, rather than (a) having to pass all known parameters to the target template, and (b) specifying the target template twice effectively. Could we consider an additional flag for wrapper which could do this? — Martin (MSGJ · talk) 12:02, 17 July 2024 (UTC)
$template-name but doesn't take a $B option. Anomie⚔ 02:29, 18 July 2024 (UTC)This module seems really poorly architected. I do not mean to slight anyone that has worked on this as it is a very useful concept and I realize it was sort of organically developed but this lack of architectural foresight now has significant implications that I want to point out. This module is heavily used to prevent template substitutions but in its 12 million plus transclusions it is basically doing nothing except getting out of the way (i.e., yielding its |$B=), however, the majority of the logic in this module comes into play during substitutions (which by definition go away at page save time) and yet the entire module is fully protected from any changes by anyone but administrators.
It seems to me it would be much more useful to develop a module that does the unsubst'ing and another module that checks for substitution and either gets out of the way or loads (on demand) the unsubst'ing module to generate a template invocation that us not subst:ed. The "get out of the way under normal transclusion" module can be a fully protected stub module transcluded upon millions of pages while the unsubst'ing module can be (mostly) unprotected because it is transcluded nowhere (because that is what substitution means).
In any event, I wanted to record my thoughts on the subject until someone comes up with a better solution (which might be me if I get the time since I am thinking about this). —Uzume (talk) 16:04, 12 October 2024 (UTC)
if mw.isSubsting() then
return require("Module:unsubst")
end
#invoke (i.e. that it's not called from other modules, which would result in breakage), which fits Wiktionary's module architecture, but may not be suitable in all Wikipedia modules. However, this shouldn't be too difficult to adapt as appropriate.{{ifsubst}} and it should not be that hard to implement a template based on that that either calls #invoke or returns the "body" or an error which could be protected and should not need much further development freeing the module to do just the wikitext template invocation construction, that won't really work as the wikitext generation module needs access to the parent frame which would be lost if there was another template in between. To that end, we do need a single "get out of the way" module that would then be able to do something like the code you provided above. I always like reading your code even when I am confused by how you write it. For example, wikt:Module:pages#L-101 could be simplified to just if type(val) ~= "table" then because it is not an error to call type on nil (or any value; it does throw an error if no value is provided though so type(fn()) might be dangerous; a clear difference using expression lists and varargs vs. assignment and function parameters where empty values are implicitly converted to nil). The same logic can be applied to simplify wikt:Module:pages#L-108--L-109 too. I often prefer to not test for nil but just check something is the type I expect and move on. I doubt the comparison prior to the call to type buys you much in terms of speed. I know Lua employs string interning (sort of like memoization) for the creation of all strings which are immutable. This means every string is compared to all the others via hash tables at creation time and that for every string with a certain value there is only a single instance. That makes ~= and == very fast for strings (i.e., literally only a reference comparison since interning guarantees no two strings can be equal unless they are the same reference). Since the results of type are severely limited, I imagine such string construction overhead is minimal and probably based upon literals. Anyway, I got off on a tangent. Thanks for the pointer to your wikt:Module:unsubst implementation. I think I meant to look at that anyway. —Uzume (talk) 01:51, 5 August 2025 (UTC){{#invoke:unsubst|me|=...}} syntax so that transclusion stub will eventually get used and eventually the module will end up protected like this one is either due to a large number of transclusions and/or sensitive ones (via a cascade).me stub like:if mw.isSubsting() then
local frame= mw.getCurrentFrame()
return require("Module:" .. frame.args[''] or mw.wikibase.getSitelink('Q15243885'))
end
local mt = {}
function mt:__index(key)
return function(frame)
return key
end
end
return setmetatable({}, mt)
me transclusion stub (instead always generating an error during transclusions) and this stub code is simple and flexible enough that protections due to high transclusion counts, etc. would not be an issue. It would also allow for potentially different kinds of unsubsting wikitext generation modules to be used for different formats, etc. (e.g., this module vs. Module:Unsubst-infobox, etc.) I appreciate your impressive wikt:Module:template parser but it is a little heavy compared to this module (although it does seem to only be called during the substing path so the impact is to page save and not to page render). —Uzume (talk) 16:31, 5 August 2025 (UTC)Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.