Howdy,

I'm building a few custom tales modifiers to use in my templates but
i've run into an issue with the syntax to use in the actual function
itself. What i've attempted to build is a tales function that formats
a number in the correct format for display on the site. There is an
example in the PHPTal manual but it must be based on an old version of
PHPTal because it fails.

What I have is this:
function phptal_tales_money($src, $nothrow) {
    $src = trim($src);
    return 'sprintf("%01.2f", ' . PHPTAL_TalesInternal::path($src,
$nothrow) . ')';
}

Using the static path method works as expected in another custom tales
function i've created, however when I use the new money: type it fails
to handle the nested php: tales.

This is the PHPTal:
<td tal:content="money: php: prodRow.getProductPrintableSellPrice()"></td>

Generated Template PHP which clearly generates a parse error:
<td><?php echo phptal_escape(sprintf("%01.2f", $ctx->php:
prodRow->getProductPrintableSellPrice()), ENT_QUOTES, 'UTF-8') ?></td>

If anyone could provide any tips on how to do it with a later version
of PHPTal that would be most appreciated.

Cheers,

James

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to