UseModWiki | WikiPatches | RecentChanges | Preferences

Subroutine Nonbreak

It may be useful to display a text phrase such that the browser treats it as un-breakable and will ensure it all apears on one line.

This subroutine can be called just like sub T, the resulting string will not be split accross lines by the browser. I suggest inserting it near to the T subroutine.

 sub Nonbreak {			# BH028
  my ($text) = @_;		# BH028
  $text =~ s/ /&nbsp/g;		# BH028  replace all spaces with non-breaking space
  return $text;			# BH028
 }				# BH028

an example of Nonbreak's use

In the sub GetFooterText routine, the username and id could be added to the footer display.
 $result .= ' ' . Nonbreak(T("You are<strong> $UserData{'username'} </strong>Id# $UserID"));   #  BH028

I have found this useful as a reminder that my user preferences are set correctly. I position it somewhere towards the right hand side of the page. By ensuring a non-breaking string, the phrase is treated as un-breakable and will jump down a line as one unit if the window is reduced in width. --BrianHunter

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 7, 2007 2:32 am by MarkusLude (diff)