diff --git a/NEWS b/NEWS index c1cbfa51..e43295c1 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ Version 2.0 ----------- + - added "eval" plugin for evaluating variables as templates (Monte) - removed $tpl_file_ext class variable, no longer used. (Monte) - added "hex" and "hexentity" escape types to escape modifier. (Monte) - removed dependency on PEAR. (Andrei) diff --git a/docs/designers.sgml b/docs/designers.sgml index 814f9f24..a5c19cd3 100644 --- a/docs/designers.sgml +++ b/docs/designers.sgml @@ -2723,6 +2723,79 @@ OUTPUT: 4<br> 6<br> 8<br> + + + + eval + + + + + + + + + + Attribute Name + Type + Required + Default + Description + + + + + var + mixed + Yes + n/a + variable (or string) to evaluate + + + + + + eval is used to evaluate a variable as a template. This can be used + for things like embedding template tags/variables into variables or + tags/variables into config file variables. + + + If you supply the special "assign" attribute, the output of the + eval function will be assigned to this template variable instead of + being output to the template. + + +eval + +setup.conf +---------- + +emphstart = <b> +emphend = </b> +title = Welcome to {$company}'s home page! +ErrorCity = You must supply a {#emphstart#}city{#emphend#}. +ErrorState = You must supply a {#emphstart#}state{#emphend#}. + + +index.tpl +--------- + +{config_load file="setup.conf"} + +{eval var=$foo} +{eval var=#title#} +{eval var=#ErrorCity#} +{eval var=#ErrorState# assign="state_error"} +{$state_error} + +OUTPUT: + +This is the contents of foo. +Welcome to Foobar Pub & Grill's home page! +You must supply a <b>city</b>. +You must supply a <b>state</b>. + +