Exchanging will make it loop through the constant string....I broke down and
created a new modifier

static public function phpeval($src, $nothrow) {
     return '$ctx->'.eval("return $src;");
}

<div id="error" tal:repeat="error phpeval:AppConstants::ERROR_KEY">
<p tal:content="error">error.</p>
</div>

Bobby

2009/4/4 Szymek Przybył <apocalyp...@gmail.com>

> <div id="error" tal:define="errorkey php:AppConstants::ERROR_KEY; errors
> ${errorkey}"
>                     tal:repeat="error errors">
> <p tal:content="error">error.</p>
> </div>
>
> Try exchange "${errorkey}" to "errorkey".
>
>
> cheers!
> szymek
>
>
>>
>> Date: Sat, 4 Apr 2009 02:15:29 +0000 (UTC)
>> From: Bobby <bobby.php...@oocr.org>
>> Subject: [PHPTAL] Missing semicolon and constants for variable keys
>> To: phptal@lists.motion-twin.com
>> Message-ID: <loom.20090404t020951-...@post.gmane.org>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> Hello, I'm new to PHPTal and i've run into a few issues...
>>
>> I want to eventually make an error list macro, my errors are sent to the
>> template under a constant key name,
>> for example:
>>
>> interface AppConstants {
>>  const ERROR_KEY = 'error_key';
>> }
>>
>> $template = new PHPTAL('example.html');
>> $template->set(AppConstants::ERROR_KEY, array('Yay, an error!', 'W00t'));
>>
>> I want to be able to retrieve it using that same constant, this is where I
>> start
>> to run into problems...
>>
>> Here's my first try in example.html:
>>
>> <div id="error" tal:repeat="error php:${AppConstants::ERROR_KEY}">
>>     <p tal:content="error">error.</p>
>> </div>
>>
>> This generates:
>>
>> $_tmp_1->error = new
>> PHPTAL_RepeatController(${AppConstants::ERROR_KEY})$ctx =
>> $tpl->pushContext() ;
>> foreach ($_tmp_1->error as $ctx->error): ;
>>
>> First, notice the missing semicolon ';' at the end of the first line
>> ..._KEY})$ctx =...
>> If I add the semicolon it will then run, ${AppConstants::ERROR_KEY} will
>> give
>> RepeatController
>> 'error_key', but without minding the real value 'error_key' in the
>> context,
>> which is understandable, the
>> result is no errors shown....
>>
>> So I try this:
>>
>> <div id="error" tal:define="errorkey php:AppConstants::ERROR_KEY; errors
>> ${errorkey}"
>>                     tal:repeat="error errors">
>> <p tal:content="error">error.</p>
>> </div>
>>
>> Which fails with the same semicolon problem as the first, but once
>> manually
>> added in will get the desired results, BUT
>> as long as we don't define errorkey as error_key which will wipeout our
>> context
>> constant.
>>
>> Why go through all this trouble when I could have just done...
>>
>> <div id="error" tal:repeat="error error_key">
>> <p tal:content="error">error.</p>
>> </div>
>>
>> Dunno....Does anyone have suggestions to improve on this? Also, how can I
>> fix
>> the missing semicolon problem?
>> (i've noticed in CodeWriter.php function flushCode that there are comments
>> "avoid adding ; after } and {" perhaps that may be preventing the
>> semicolon?)
>>
>> Thanks!
>>
>> Bobby
>>
>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL@lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
>>
>>
>> End of PHPTAL Digest, Vol 50, Issue 1
>> *************************************
>>
>
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
>
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to