Jump to content

Template talk:Break

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Edit request from Who R you?, 11 October 2011

[edit]

This code can be slightly more efficient (68chars / 4.6% smaller) and currently has the following minor bugs:

  • For parameter (number of breaks to insert) <= 0, current version still inserts a single break; the new version does not (as should be the case).
  • If parameter (number of breaks to insert) > 20 (template maximum), current version defaults to a single break; new version defaults to maximum (20) (which would seem to be the logical choice).

The revised code exists at User:Who R you?/sandbox15 with full test results in User:Who R you?/sandbox15/testcase (columns 1 & 2).  Documentation remains unchanged.

To implement the change: Cut & Paste the code from User:Who R you?/sandbox15 to {{ Break}}.

Note: I created another much (38.4%) smaller version by having a template call a sub-template (see: User:Who R you?/sandboxes 15b and 15c), but some strange results occurred.  Someone with some serious wiki technical skills may wish to investigate this apparent wiki bug (see columns 3 & 4 of the testcase).  However this doesn't affect the revision requested above.

Who R you? (talk) 04:24, 11 October 2011 (UTC)[reply]

I had a little tweak and tried to improve it (see my edit summaries), but then got confused! Perhaps you could check what I did? — Martin (MSGJ · talk) 15:00, 11 October 2011 (UTC)[reply]
I can't believe I didn't think to try the sausage .  I added the error trapping; nice catch!
I previously left the SafeSubst untouched as I wasn't really sure what it was and hadn't bothered to look it up; but having done so now, considering that the template's documentation states the original purpose of the template was to prevent bots automatically "fixing" the error of multiple <br />s, I would think substing even the old version would have been self−defeating since a bot would just fix it again, wouldn't it?  Regardless, you're right, it's unnecessary & inappropriate.
Regarding the whitespace additions, I can understand why you'd do so while reviewing the code; but given that this is non−compiling code, my goal was to reduce overall size of the code to the bare minimum, thereby improving performance.  In that sense only, the whitespace & commenting are self−defeating of that purpose since they actually bloat the code up larger than it began (although with the addition of error trapping and corrected support for param <= 0 or > max, that might still be acceptable).
I suggest it'd make the most sense to saving the changes in {{Break}} (with the whitespace & commenting intact) with an edit summary like ‘Smaller code, error checking added & minor fix -- Version with annotations’, then edit the template a second time to save it with whitespace & comments removed and an appropriate edit summary like ‘Smaller code; error checking added & minor fix -- Uncommented version’; the edit history can then be viewed to provide some explanation of the logic, in a more readable form; but resaving with whitespace & comments removed will permit for the smallest possible code and presumable the most efficient possible server−side workload.  While a ~4% code reduction in something this small doesn't really amount to that much, the fact that this template is transcluded into thousands of articles should mean that even such a minor reduction could amount to some non−trivial reduction in server demands and memory use.
I followed my own advice and saved it (the sandbox version) in a documented/readable form first, and then resaved it in an undocumented/smallest possible form so you can cut & paste over the two successive versions as easily as possible.  Of course, if you can think of any other improvements (that error trapping was a good catch), by all means make the changes or let me know; but I can't think of much more to do with this.  And as for the other version (15b & 15c), particularly since I can't ever see a reasonable use for adding more than 20 successive <br />s anywhere, and given the various wiki glitches it exposes, I can't see any purpose in pursuing that line other than to perhaps investigate said glitches.  Anyways Martin, thanks for your assistance. Who R you? (talk) 08:14, 12 October 2011 (UTC)[reply]
Okay, happy to deploy the code! But am a little confused about your concern about whitespace. Generally we do not worry about performance issues and anyway whitespace makes negligible difference to the performance of a template. If it helps other editors to understand the code I think that is much more beneficial. — Martin (MSGJ · talk) 17:02, 12 October 2011 (UTC)[reply]
Fair enough on the whitespace; just my old−school programming background; I still think code in every byte counts mindset; granted far less today than it once did; (but I still generally prefer to opt for the smaller code choice; a byte in memory is still a byte in memory & one or two bytes is often the threshold for another sector on the hard−drive being repeatedly read with each call of the template).  But as you say, performance impact in that respect is potentially immaterial.  BTW thx for the ref to WP:PERF.  — Who R you? (talk) 06:37, 13 October 2011 (UTC)[reply]

Moved from {{crlf}}

[edit]
moved from Template talk:Crlf which is now a redirect to here (see wp:TfD) - Nabla (talk) 12:09, 21 June 2015 (UTC)[reply]

Examples

[edit]
:Line 1{{crlf
|}}Line 2

gives:

Line 1
Line 2
*Line 1{{crlf
|}}Line 2

gives:

  • Line 1
    Line 2

No line split?

[edit]

I query the claim "a normal <br /> can only be called with:

<br />

on one line". Where is this documented? It also doesn't seem to be true: the markup

(First sentence<br
/>Second sentence.)

produces (First sentence
Second sentence.) As may be seen, there is a line break there. In HTML, spaces and newlines are equivalent, as are other whitespace characters such as tabs. --Redrose64 (talk) 12:54, 10 May 2015 (UTC)[reply]

Deletion nomination

[edit]

I've nominated this template for deletion. Alakzi (talk) 23:28, 3 June 2015 (UTC)[reply]

Template-protected edit request on 10 November 2015

[edit]

I have added a shortcut to the template {{break}} via a template redirect called {{brk}}. Please "protect" the {{brk}} template redirect. Thank you. {{u|Checkingfax}} {Talk} 09:22, 10 November 2015 (UTC)[reply]

Not done: this is the talk page for discussing improvements to the template {{Break}}. Please make your request at WP:RPP. Bazj (talk) 09:45, 10 November 2015 (UTC)[reply]
(edit conflict) Please use WP:RFPP for protection requests. Template editors can't protect pages. SiBr4 (talk) 09:46, 10 November 2015 (UTC)[reply]
 Done Thank you. Cheers! {{u|Checkingfax}} {Talk} 08:37, 11 November 2015 (UTC)[reply]

Refactored

[edit]

per the associated TfD for "Module:Break", I have refactored the code to use "Module:String". let me know if you see any problems. Frietjes (talk) 17:10, 4 January 2018 (UTC)[reply]

"Template:Br" listed at Redirects for discussion

[edit]

An editor has identified a potential problem with the redirect Template:Br and has thus listed it for discussion. This discussion will occur at Wikipedia:Redirects for discussion/Log/2021 December 24#Template:Br until a consensus is reached, and readers of this page are welcome to contribute to the discussion. – Jonesey95 (talk) 22:22, 24 December 2021 (UTC)[reply]