Template:Nowordbreak/doc: Difference between revisions

From DynamicPageList3 Manual
Content deleted Content added
imported>FrozenPlum
Move the documentation to subpage
 
imported>FrozenPlum
m update text to match the requirements (it ignored the variables extension requirement) and amend categories
 
Line 3:
This template will return the first n characters of a string, without breaking words. Numbers however, will be broken apart.
 
Note: This template requires the [[mw:Extension:RegexFunctions|RegexFunctions]] extension and the [[mw:Extension:Variables|Variables]] extension (whose future is uncertain).
 
=== Usage examples ===
Line 21:
[[Category:Uses Variables extension]]
[[Category:Uses RegexFunctions extension]]
[[Category:Templates to simplify or eliminate]]
</includeonly>

Latest revision as of 03:17, 30 March 2022

This is the documentation page, it should be transcluded into the main template page. See Template:Documentation for more information

This template will return the first n characters of a string, without breaking words. Numbers however, will be broken apart.

Note: This template requires the RegexFunctions extension and the Variables extension (whose future is uncertain).

Usage examples

Code Gives
{{nowordbreak|Testing, testing, 123|11}} 11}}{{#vardefine:text|Testing, testing, 123}}{{#vardefine:sub|{{#sub:{{#var:text}}|0|{{#var:n}} }} }}{{#vardefine:n+|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:sub+|{{#sub:{{#var:text}}|0|{{#var:n+}} }} }}{{#rmatch:{{#var:sub}}|/[\W0-9]$/|{{#var:sub}}|{{#rmatch:{{#var:sub+}}|/[\W0-9]$/|{{#var:sub}}|{{#rmatch:{{#var:sub}}|/^(.*[\s]).*$/|$1|{{#var:sub}}}}}}}}
{{nowordbreak|Testing, testing, 123|20}} 20}}{{#vardefine:text|Testing, testing, 123}}{{#vardefine:sub|{{#sub:{{#var:text}}|0|{{#var:n}} }} }}{{#vardefine:n+|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:sub+|{{#sub:{{#var:text}}|0|{{#var:n+}} }} }}{{#rmatch:{{#var:sub}}|/[\W0-9]$/|{{#var:sub}}|{{#rmatch:{{#var:sub+}}|/[\W0-9]$/|{{#var:sub}}|{{#rmatch:{{#var:sub}}|/^(.*[\s]).*$/|$1|{{#var:sub}}}}}}}}