Bill Moseley wrote:
> And would it be smart to have a TEMPLATE_ENCODING config option to
> tell Provider how to decode the content if not BOM is not found?

Hi Bill, 

Yes, this is a good idea.

> An unanswered question is should TT also encode output, or should
> setting the output io layer be left to the user?

We can probably have one ENCODING config option to specify the default
encoding for both input and output templates.  

If we know the specific encoding of the source template (either by BOM or 
some kind of in-template flag) then we can also set the output encoding.

> If you want I can try and find time for docs and test case, although
> the decode() I added only generates warnings (CHECK not set), and I'm
> not sure how to get Template::Test to check for warnings.  That's
> something you are probably more familiar with.

I've applied your patch, although as ENCODING rather than TEMPLATE_ENCODING.
Tests and docs would be great.

To catch warnings I usually do something like this:

  my $warning;
  local $SIG{__WARN__} = sub {
      $warning = shift;
  };

  my $vars = {
    warning => sub { return $warning },
  };

  test_expect(\*DATA, undef, $vars);

  __DATA__
 
  -- test --
  action: [% do_something('wrong') or 'failed' %]
  warning: [% warning %]
  -- expect --
  action: failed
  warning: do_something() does not accept a 'wrong' argument
  
> I also think something like Tatsuhiko Miyagawa's T::P::Encoding
> module would be nice core feature since specifying the encoding of a
> template is rather fundamental.  

Yes, I agree.  But the ad-hoc way of specifying the encoding isn't 
reliable enough. 

> Could it be part of META, I wonder?
> 
>     [% META encoding = 'utf8' %]

That's preferable, but as you point out, we need to determine the encoding
before we start scanning the content.  I suppose we could assume ASCII
until we detect an encoding META tag, then decode the content, then start
parsing again.

For this release, I think we'll offer the ENCODING option and try and solve
the in-template encoding specification problem another day.

Cheers
A



_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to