Re: [Templates] Processing Variables as templates

[prev] [thread] [next] [Date index for 2004/08/06]

From: Darren Chamberlain
Subject: Re: [Templates] Processing Variables as templates
Date: 14:41 on 06 Aug 2004
--qD3brAgIG4LbUq6d
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Harry Jackson <h.jackson at acu.ac.uk> [2004/08/06 15:35]:
> I need some way to be able to do the following.

Pipe CONTENT_NAME through the eval filter:

  [% CONTENT_NAME | eval %]

perldoc Template::Filters sez:

  eval / evaltt

  The eval filter evaluates the block as template text, processing any
  directives embedded within it.  This allows template variables to
  contain template fragments, or for some method to be provided for
  returning tem- plate fragments from an external source such as a
  database, which can then be processed in the template as required.

      my $vars  =3D {
          fragment =3D> "The cat sat on the [% place %]",
      };
      $template->process($file, $vars);

  The following example:

      [% fragment | eval %]

  is therefore equivalent to

      The cat sat on the [% place %]

  The evaltt filter is provided as an alias for eval.

(darren)

--=20
If we can't be free at least we can be cheap.

--qD3brAgIG4LbUq6d
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBE5iCzsinjrVhZaoRAiX+AJ4+hbBHAhkHpu2Bx6gy/YdZzSn6pQCgpjwZ
78V3bGpqm9TAxrkDXwDVmKE=
=OnBT
-----END PGP SIGNATURE-----

--qD3brAgIG4LbUq6d--

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Processing Variables as templates
Harry Jackson 14:35 on 06 Aug 2004

Re: [Templates] Processing Variables as templates
Darren Chamberlain 14:41 on 06 Aug 2004

Re: [Templates] Processing Variables as templates
Harald Joerg 14:53 on 06 Aug 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52