velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <jrevu...@terra.es>
Subject Re: template encodings
Date Mon, 16 Jul 2001 00:09:57 GMT
"Geir Magnusson Jr." wrote:
> 
> Jonathan Revusky wrote:
> >
> > "Geir Magnusson Jr." wrote:
> > >
> > > Jonathan Revusky wrote:
> > > >
> > > > "Geir Magnusson Jr." wrote:
> > > > > >
> > > > > > Actually, I missed that the mergeTemplate took the *name* of
the
> > > > > > template as well. I also just was wondering what the extent
to which
> > > > > > this had been investigated and tested was.
> > > > >
> > > > > Extend to which *what* has been investigated and tested???  Is there
a
> > > > > bug?
> > > >
> > > > The "what" is using Velocity in locales with other character encodings.
> > > > I am not reporting a bug. I was asking question or two, but now I
> > > > understand pretty much completely where things are at, I think.
> > > >
> > >
> > > Just to be clear, for anyone looking at this thread, or finding it in
> > > the archives -
> > >
> > > Velocity works well in locales with non- ISO-8859-1 (latin) character
> > > encodings.  Of the top of my head, I know that people have used it with
> > > encodings appropriate for Russian, Japanese, Chinese, French, Spanish
> > > and Finnish users.
> >
> > You should have stopped at Chinese. :-) French, Spanish, and Finnish use
> > the default ISO-8859-1 (latin) character encoding anyway, so there's no
> > issue.
> 
> The spanish was in UTF-8.

This strikes me as rather odd. AFAIK, the default encoding for a
Spanish-language locale is ISO-8859-1. I should know. I'm writing you
from Spain. I often use machines with a Spanish-localized OS. Did
somebody write, explicitly saying he was storing Spanish-language
templates in a UTF-8 encoding?


> 
> > The other ones you mention are interesting to know about though.
> >
> > I did not mean to suggest that it didn't work. I have every reason to
> > believe that it does, since the java I/O libraries are what are
> > providing the support. It's just a question of knowing where the hooks
> > are.
> 
> er, yeah...
> 
> public Template getTemplate( String template, String encoding)

I was confused at the moment because there was another API called
mergeTemplate and I didn't understand it at the moment. I wrote a
message about that. Though I was a bit fuzzy-headed when I posed the
question, but that occurs frequently....

Also, it is not as simple as you're suggesting because somebody could
easily assume (perhaps naively) that if they called getTemplate as above
with a given encoding, that this would imply that it would be output
with the same encoding by default. (I know that people should not
automatically assume this in an ideal world, but still, it is a
legitimate questions one could ask about this...)

None of this is rocket science, mind you, but if you want to develop a
product for rocket scientists, well, then, be my guest...

> 
> 
> > Also, I understand that the input encoding, theoretically, is not
> > necessarily the same as the output encoding. You could, for example,
> > store all of the templates in UTF-8 and then output them via the
> > localized encodings. I was simply expressing doubt that this is very
> > common in practice. In my own framework, I am currently assuming that
> > the input and output encodings are the same, since this allows me to
> > keep my API simpler and hide messy stuff from the end user, which is the
> > goal. If this turns out to be an issue, I'll revisit it.
> 
> Ok.  Whatever floats your boat.

Well, of course. I was my talking about my library and yes, I'll do
whatever I judge best. Though I could be interested in feedback about
whether that is the appropriate course. I am not absolutely sure.
Meanwhile, I have received responses that I find kind of... weird... 

Look, there is a real issue here where I have the unmistakeable
impression that you guys have a chip on your shoulders. Okay, Jon
Stevens obviously does and it's pretty explicit. You, on the other hand,
are more of a "mailed fist in velvet glove" type. In a way, that's
actually worse IMO...

In the past few days, you guys have received various useful bits of
feedback -- not from me, but from other people. Examples: The usage of
the "." as the default location to load templates from is of course
utterly useless because the current working directory is meaningless in
the context AFAICS. Or IOW, the default is almost guaranteed to not
behave in any desirable way. Somebody else pointed out that if you
specifically give an absolute location for the template file, it doesn't
work, i.e. some naive user who tries:
getTemplate("C:\\mytemplates\\mytemplate.html"). Well, that's basically
a bug. The default code should have the smarts that if you give it an
absolute path AND the file is there and readable, it should use it. To
have any other behavior is to willfully waste people's time.

I agree that it's not good practice to use absolute paths, but there is
a principle here called "the principle of least surprise" that you are
failing to follow in the above. In general, Brad Cox was quite right
that the "ResourceLoader" configuration business is overly complicated.
It does not particularly surprise me that he had problems getting
Velocity working. The basic rule of thumb is that if 1 person writes you
saying that, then there are at least 10 other people who had the same
problem and did not write.

The criticism that you are making excessive use of static methods to
vend objects is certainly well founded too, but I would be reluctant to
press that one too much, since I don't have an easy alternative and I
tend to use the same pattern in my own code. Still, that critique made
me think twice about where I was doing that and I will look for better
ways.

In short, Velocity is a pretty good product, but it certainly could be
better. And really, the fact is, that over the past couple of years lots
of people have written these HTML template languages for the web.
Undoubtedly, a number of people wrote template engines as ungraduate
senior-year projects in a CS program...  Some of the many template
engines are better than others, but the reason that Velocity has as much
usage as it does is because of the apache.org linkage. It is not
particularly due to intrinsic merit. 

This last point I'm making may be considered a gratuitous jab, but
really, it has a purpose. It is meant to puncture your insufferable
arrogance. (Also, I'm quite satisfied that the comment is true.)

So now, fellas, do be good...

:-)

> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!

-- 
Jonathan Revusky
--
available for Java/Delphi/Internet consulting
If you want to...
- make your .class files double-clickable with SmartJ
- do Delphi/Java mixed programming with easy-to-use JNI wrapper classes
- build robust web applications with the Niggle Application Framework
then...
check out the Revusky Hacks Page: http://www.revusky.com/hacks/

Mime
View raw message