Text spacers - What do you use?
flag
Messages 1 - 10 of 51 - Collapse all
/groups/adfetch?adid=I-7KkA8AAADQZUlZKH-KmxlRa-oiI8Xf
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
1.  Ed Jay  
View profile  
 More options Nov 22 2005, 8:20 pm
Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 17:20:43 -0800
Local: Tues, Nov 22 2005 8:20 pm
Subject: Text spacers - What do you use?
I'm generating an HTML report page using Perl. I'm reticent to use a table
for formatting the page. What do most folks use for text spacers?

As I see it, I can use a javascript loop to generate a passed value of
spaces (&nbsp;) or I can use a blank, one-pixel tall gif and pass the
width parameter to a javascript. (All my users will have js enabled.)

Or, should I generate the space within Perl?

--
Ed Jay (remove M to respond by email)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
2.  Mark Parnell  
View profile  
 More options Nov 22 2005, 8:26 pm
Newsgroups: alt.www.webmaster
From: Mark Parnell <webmas...@clarkecomputers.com.au>
Date: Wed, 23 Nov 2005 12:26:23 +1100
Local: Tues, Nov 22 2005 8:26 pm
Subject: Re: Text spacers - What do you use?
In our last episode, Ed Jay <ed...@aes-intl.com> pronounced to
alt.www.webmaster:

> I'm generating an HTML report page using Perl. I'm reticent to use a table
> for formatting the page.

Why? Is it not tabular data? <pre> may be an option. It's hard to say
from the information given.

Ultimately, format it the same way you would if you were writing the
page yourself. Just get Perl to generate the markup.

--
Mark Parnell
http://clarkecomputers.com.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
3.  John Bokma  
View profile  
 More options Nov 22 2005, 8:37 pm
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 01:37:08 GMT
Local: Tues, Nov 22 2005 8:37 pm
Subject: Re: Text spacers - What do you use?

Ed Jay <ed...@aes-intl.com> wrote:
> I'm generating an HTML report page using Perl. I'm reticent to use a
> table for formatting the page. What do most folks use for text
> spacers?

&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;

> As I see it, I can use a javascript loop to generate a passed value of
> spaces (&nbsp;) or I can use a blank, one-pixel tall gif and pass the
> width parameter to a javascript. (All my users will have js enabled.)

> Or, should I generate the space within Perl?

print "<br>\n" for 1 .. 100000;         # outer space

Ok, the real answer: if you want to use tables, you could set a margin on
the table element over which you have quite some control.

--
John                       Perl SEO tools: http://johnbokma.com/perl/
                                             or have them custom made
                 Experienced (web) developer: http://castleamber.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
4.  Ed Jay  
View profile  
 More options Nov 22 2005, 8:55 pm
Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 17:55:17 -0800
Local: Tues, Nov 22 2005 8:55 pm
Subject: Re: Text spacers - What do you use?

John Bokma <j...@castleamber.com> wrote:
>Ed Jay <ed...@aes-intl.com> wrote:

>> I'm generating an HTML report page using Perl. I'm reticent to use a
>> table for formatting the page. What do most folks use for text
>> spacers?

>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;

I'm going blind reading my Perl scripts as it is. The above will serve
only to further my blindness. :-)

>> As I see it, I can use a javascript loop to generate a passed value of
>> spaces (&nbsp;) or I can use a blank, one-pixel tall gif and pass the
>> width parameter to a javascript. (All my users will have js enabled.)

>> Or, should I generate the space within Perl?

>print "<br>\n" for 1 .. 100000;     # outer space

I'd replace <br> with &nbsp;. :-)

But, this is what I'm think of. For example, call a function along the
lines print "text\n"; spaceFunction(35); print "more text\n";

where spaceFunction() is a js scripted loop that generates n spaces and in
my example, it would print 35 spaces between text and more text.

>Ok, the real answer: if you want to use tables, you could set a margin on
>the table element over which you have quite some control.

Tables are no problem, except I've adopted the discipline of using CSS for
layout.

Mark Parnell <webmas...@clarkecomputers.com.au> wrote:
>Why? Is it not tabular data? <pre> may be an option. It's hard to say
>from the information given.

I wouldn't call it tabular data.
Name                                             Date
City                          State              Zip
etc.

>Ultimately, format it the same way you would if you were writing the
>page yourself. Just get Perl to generate the markup.

Understood. I'm trying to overcome writing n-spaces or having a bunch of
blank images in the raw Perl script.

--
Ed Jay (remove M to respond by email)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
5.  John Bokma  
View profile  
 More options Nov 22 2005, 9:14 pm
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 02:14:38 GMT
Local: Tues, Nov 22 2005 9:14 pm
Subject: Re: Text spacers - What do you use?

Then you forgot the most important rule: be lazy. In Perl you could
write the above as:

print ( ( '&nbsp;' x 12, "\n" ) x 4 );

> The above will serve
> only to further my blindness. :-)

So... get lazy :-D

>>print "<br>\n" for 1 .. 100000;         # outer space

> I'd replace <br> with &nbsp;. :-)

> But, this is what I'm think of. For example, call a function along the
> lines print "text\n"; spaceFunction(35); print "more text\n";

Don't

> where spaceFunction() is a js scripted loop that generates n spaces
> and in my example, it would print 35 spaces between text and more
> text.

Don't. Just set a margin on your table.

>>Ok, the real answer: if you want to use tables, you could set a margin
>>on the table element over which you have quite some control.

> Tables are no problem, except I've adopted the discipline of using CSS
> for layout.

So, there you go

Please don't reply to 2 people in one reply.

--
John                       Perl SEO tools: http://johnbokma.com/perl/
                                             or have them custom made
                 Experienced (web) developer: http://castleamber.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
6.  Ed Jay  
View profile  
 More options Nov 22 2005, 9:21 pm
Newsgroups: alt.www.webmaster
From: Ed Jay <ed...@aes-intl.com>
Date: Tue, 22 Nov 2005 18:21:51 -0800
Local: Tues, Nov 22 2005 9:21 pm
Subject: Re: Text spacers - What do you use?

That should work.

I got lazy... ;-)

Thanks.

--
Ed Jay (remove M to respond by email)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
7.  mbstevens  
View profile  
 More options Nov 22 2005, 10:23 pm
Newsgroups: alt.www.webmaster
From: mbstevens <NOXwebmast...@xmbstevensx.com>
Date: Wed, 23 Nov 2005 03:23:58 GMT
Local: Tues, Nov 22 2005 10:23 pm
Subject: Re: Text spacers - What do you use?

Ed Jay wrote:
> John Bokma <j...@castleamber.com> wrote:

>>Ed Jay <ed...@aes-intl.com> wrote:

>>>I'm generating an HTML report page using Perl. I'm reticent to use a
>>>table for formatting the page. What do most folks use for text
>>>spacers?

>>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;
>>&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;

Ooook.  Please tell me you forgot your smiley.
You can style generated pages with CSS the same as regular pages.

> I'm going blind reading my Perl scripts as it is. The above will serve
> only to further my blindness. :-)

Probably lack of comments and sloppy indentation.  All legal in Perl but
bad style.
Give yourself a break.  As you write, think kind thoughts of you future
self.

>>>As I see it, I can use a javascript

Don't _even_ go there.

  loop to generate a passed value of

>>>spaces (&nbsp;) or I can use a blank, one-pixel tall gif and pass the
>>>width parameter to a javascript. (All my users will have js enabled.)

>>>Or, should I generate the space within Perl?

>>print "<br>\n" for 1 .. 100000;         # outer space

That gets very tiresome and hard to read.  Here, have a look:
http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi

> I'd replace <br> with &nbsp;. :-)

> But, this is what I'm think of. For example, call a function along the
> lines print "text\n"; spaceFunction(35); print "more text\n";

> where spaceFunction() is a js scripted loop that generates n spaces and in
> my example, it would print 35 spaces between text and more text.

Again, OOOOk.

Whether it's tabular or not, style it with CSS.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
8.  John Bokma  
View profile  
 More options Nov 22 2005, 10:54 pm
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 03:54:14 GMT
Local: Tues, Nov 22 2005 10:54 pm
Subject: Re: Text spacers - What do you use?

Yeah, I did (although I use in a very few locations indeed &nbsp;)

>>>print "<br>\n" for 1 .. 100000;         # outer space

> That gets very tiresome and hard to read.

Why?

Done, I hope you be prepared :-D.

sub dofile              - pick a good sub routine name
my $ff = shift;                 - pick a clear variable name

open(XIN, "$ff") || err('open', $ff );

has a few:

        - you should localize XIN, or better, see below
        - you *shouldn't* put quotes around ""
        - you *should* use the value of $! in your error report (how can  
          you else know what went wrong)?

to summarize:

open my $fh, $filename
    or die "Couldn't open '$filename' for reading: $!";

(I recommend using CGI::Carp 'fatalsToBrowser' instead of home brew err
 thingies)

If you're paranoid, you could add \n after $!.

make_substitutions @dat;        - probably smarter to pass around a as    
                                          ref

print "@dat\n";

        - "@dat" does join ' ' => @dat, I doubt you really want that
        - why an extra newline? You are adding stuff that's not in your
         template file

foreach my $s (@_) {

        $s =~ s/TEMPLATE_REPLACE_FNAME/$nm/eg;

has a few to:

        - by dropping the $s (or pick a good name), you can actually make
         your code more readable
        - e is not needed on s///; so:

for ( @_ ) {

        s/TEMPLATE_REPLACE_FNAME/$nm/g;
        :
        :
        s/TEMPLATE_REPLACE_TITLE/$title/g;

}

which has some another thing: it uses globals (yikes).

by a lottle [1] rewriting, you might get:

sub use_template_file {

        my ( $filename, $variables ) = @_;

        open my $fh, $filename
            or die "Can't open template '$filename' for reading: $!";
        while ( <$fh> ) {

                s{TEMPLATE_REPLACE_(\w+)}{

                        defined $variables->{ lc $1 }
                                ?  $variables->{ lc $1 }
                                :  "$1 not defined"
                }ge;

                print;
        }

        close $fh
            or die "Can't close template '$filename' after reading: $!";

}                

use_template_file(

        'helloworld.tmp', {

                title => 'Hello, world!',
                :
                :
        }
);

(untested, assumes a Content-type header has already been printed).

[snip noise]

[1] not a little

--
John                       Perl SEO tools: http://johnbokma.com/perl/
                                             or have them custom made
                 Experienced (web) developer: http://castleamber.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
9.  mbstevens  
View profile  
 More options Nov 23 2005, 12:03 am
Newsgroups: alt.www.webmaster
From: mbstevens <NOXwebmast...@xmbstevensx.com>
Date: Wed, 23 Nov 2005 05:03:54 GMT
Local: Wed, Nov 23 2005 12:03 am
Subject: Re: Text spacers - What do you use?

John Bokma wrote:

>>>>print "<br>\n" for 1 .. 100000;         # outer space

>>That gets very tiresome and hard to read.

> Why?

Not tiresome to read in Perl, but tiresome to read in
the markup.  Who wants to see a thousand breaks?

>>Here, have a look:
>>http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi

> Done, I hope you be prepared :-D.

> sub dofile                 - pick a good sub routine name
> my $ff = shift;                    - pick a clear variable name

You do realize this is a local in an eight line function?

> open(XIN, "$ff") || err('open', $ff );

> has a few:

>            - you should localize XIN, or better, see below

The program uses strict and doesn't complain.  $ff, the string that
opens the file, is localized.  XIN is a file handle.
The way you've done it in your version below is not a practice I've
often seen.  People reading code expect to see file handles in all caps.
  Your version using
        "open my $fh, $filename"
...is not  as readable.  I can just glance at a function with file
handles in all caps and say "hey, the programmer is playing with files
here."  I see no reason to torture myself over the niceties of
localization and globalization in such a short program.  If I ever roll
the two tiny functions into an object, It'll get taken care of.

>            - you *shouldn't* put quotes around ""

I can't seem to find what you're talking about.

>            - you *should* use the value of $! in your error report (how can  
>              you else know what went wrong)?

That's reasonable.   I might add that to the error function.

> to summarize:

> open my $fh, $filename
>     or die "Couldn't open '$filename' for reading: $!";

> (I recommend using CGI::Carp 'fatalsToBrowser' instead of home brew err
>  thingies)

> If you're paranoid, you could add \n after $!.

> make_substitutions @dat;           - probably smarter to pass around a as    
>                                      ref

Why better?  Works fine as it is.

> print "@dat\n";

>            - "@dat" does join ' ' => @dat, I doubt you really want that
>            - why an extra newline? You are adding stuff that's not in your
>          template file

Insurance against no newline at the end of the file, so that the markup
will be guaranteed to be readable.  You're welcome to drop it if you want.

> foreach my $s (@_) {

>            $s =~ s/TEMPLATE_REPLACE_FNAME/$nm/eg;

> has a few to:

>            - by dropping the $s (or pick a good name), you can actually make
>          your code more readable
>            - e is not needed on s///; so:

I think $s for string is quite good enough for a 6 line function.

> for ( @_ ) {

>            s/TEMPLATE_REPLACE_FNAME/$nm/g;
>            :
>            :
>            s/TEMPLATE_REPLACE_TITLE/$title/g;
> }

> which has some another thing: it uses globals (yikes).

This is a situation where globals are perfectly OK.   It could easily be
rolled into an object, but for such a short program, why bother?  It's
easier for the visitor to modify functions to suit their needs when
they're this small.  Perl doesn't _force_ you to write very short
programs as objects.  I really think that with your love of
encapsulation you would be much more happy with Python.  I like Python,
too, but this ain't Python.

> by a lottle [1] rewriting, you might get:

> sub use_template_file {

>            my ( $filename, $variables ) = @_;

>            open my $fh, $filename
>                or die "Can't open template '$filename' for reading: $!";

I really prefer my own error function to this kind of thing.  It can
also be used for errors other places in the program.

>            while ( <$fh> ) {

>                    s{TEMPLATE_REPLACE_(\w+)}{

>                            defined $variables->{ lc $1 }
>                                    ?  $variables->{ lc $1 }
>                                    :  "$1 not defined"
>                    }ge;

>                    print;
>            }

>            close $fh
>                or die "Can't close template '$filename' after reading: $!";
> }  

I think my way of breaking this into two functions instead of one long
function is much more readable.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
10.  John Bokma  
View profile  
 More options Nov 23 2005, 1:55 am
Newsgroups: alt.www.webmaster
From: John Bokma <j...@castleamber.com>
Date: 23 Nov 2005 06:55:39 GMT
Local: Wed, Nov 23 2005 1:55 am
Subject: Re: Text spacers - What do you use?

mbstevens <NOXwebmast...@xmbstevensx.com> wrote:
> John Bokma wrote:

>>>>>print "<br>\n" for 1 .. 100000;         # outer space

>>>That gets very tiresome and hard to read.

>> Why?

> Not tiresome to read in Perl, but tiresome to read in
> the markup.  Who wants to see a thousand breaks?

How many people do read the mark up?

>>>Here, have a look:
>>>http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi

>> Done, I hope you be prepared :-D.

>> sub dofile                  - pick a good sub routine name
>> my $ff = shift;                  - pick a clear variable name

> You do realize this is a local in an eight line function?

XIN? no, it's not local :-)

>> open(XIN, "$ff") || err('open', $ff );

>> has a few:

>>          - you should localize XIN, or better, see below

> The program uses strict and doesn't complain.

it has nothing to do with strict.

> $ff, the string that
> opens the file, is localized.

no, it's a lexical scoped variable (IIRC there is a difference :-)

> XIN is a file handle.
> The way you've done it in your version below is not a practice I've
> often seen.

It's documented in perldoc -f open

> People reading code expect to see file handles in all
> caps.

note that there is a difference between XIN and my $fh.

>   Your version using
>           "open my $fh, $filename"
> ...is not  as readable.

Because it's new to you?

> I can just glance at a function with file
> handles in all caps and say "hey, the programmer is playing with files
> here."

in that case you could use $file_handle, or even $FILE_HANDLE, although
the latter is confusing, since to me that looks like a scalar holding a
constant.

> I see no reason to torture myself over the niceties of
> localization and globalization in such a short program.

Since I read the snippet as an example, I recommend to show good
programming practices in an example. I read, reread and rerereread my
Perl code examples many times before I put them on my site :-)

> If I ever
> roll the two tiny functions into an object, It'll get taken care of.

>>          - you *shouldn't* put quotes around ""

open(XIN, "$ff")
           ^^^^

Somehow I forgot to make clear around what :-)

> I can't seem to find what you're talking about.

>>          - you *should* use the value of $! in your error report (how
>>          can  
>>             you else know what went wrong)?

> That's reasonable.   I might add that to the error function.

I recommend to not add it to the error function, since it's value might
not always be as expected, better to pass it to the error function, or
better use die with CGI::Carp 'fatalsToBrowser';

>> make_substitutions @dat;         - probably smarter to pass around a
>> as    
>>                                            ref

> Why better?  Works fine as it is.

better since the whole array is copied into memory. When passing around
arrays, especially when they can be large, it's better to use a
reference.

>> print "@dat\n";

>>          - "@dat" does join ' ' => @dat, I doubt you really want that
>>          - why an extra newline? You are adding stuff that's not in
>>          your template file

> Insurance against no newline at the end of the file, so that the
> markup will be guaranteed to be readable.  You're welcome to drop it
> if you want.

Uhm, how does an \n at the end of the file make the markup more
readable?

However, the other question is more important, you add extra spaces
between your lines. This might result in odd results when you use
preformatted text, e.g.

<pre><code>print
hello, world!</code></pre>

becomes

<pre><code>print
 hello, world!</code></pre>

which renders as

print
 hello, world!

>> foreach my $s (@_) {

>>          $s =~ s/TEMPLATE_REPLACE_FNAME/$nm/eg;

>> has a few to:

>>          - by dropping the $s (or pick a good name), you can actually
>>          make your code more readable
>>          - e is not needed on s///; so:

> I think $s for string is quite good enough for a 6 line function.

If so, then so is $_, which is implicit, and hence you can drop it :-D

>> for ( @_ ) {

>>          s/TEMPLATE_REPLACE_FNAME/$nm/g;
>>          :
>>          :
>>          s/TEMPLATE_REPLACE_TITLE/$title/g;
>> }

>> which has some another thing: it uses globals (yikes).

> This is a situation where globals are perfectly OK.

To me, no. Since this is cleary a snippet that is going to be part of
another (CGI) program.

> It could easily
> be rolled into an object, but for such a short program, why bother?

Because it's not a program. It's a piece of code you suggest someone can
add to a program.

> It's easier for the visitor to modify functions to suit their needs
> when they're this small.  Perl doesn't _force_ you to write very short
> programs as objects.  I really think that with your love of
> encapsulation you would be much more happy with Python.  I like
> Python, too, but this ain't Python.

No, it has nothing to do with OO programming, nor encapsulation. I
recommend not to use globals in general.

>> by a lottle [1] rewriting, you might get:

>> sub use_template_file {

>>          my ( $filename, $variables ) = @_;

>>          open my $fh, $filename
>>              or die "Can't open template '$filename' for reading:
>>              $!";

> I really prefer my own error function to this kind of thing.  It can
> also be used for errors other places in the program.

Uhm, die is an error function, overloaded by CGI::Carp. And you can use
it in other places in your program. Moreover, die is what a lot of
programmers recognize and understand. err has to be looked up...

[ .. ]

> I think my way of breaking this into two functions instead of one long
> function is much more readable.

Note that my function is just 7 lines. I use a lot of white space. Also
note that my function works as easy with 1 variable as with 1000.
make_substitutions needs an additional line for each substitution.

--
John                       Perl SEO tools: http://johnbokma.com/perl/
                                             or have them custom made
                 Experienced (web) developer: http://castleamber.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2013 Google