#2349 - Implement proper Tempcode binding

Identifier #2349
Issue type Feature request or suggestion
Title Implement proper Tempcode binding
Status Completed
Tags

Risk: General incompatibility (custom)

Handling member Chris Graham
Addon newsletter
Description Currently the Tempcode is bound into newsletter instances via a hack:

foreach ($vars as $var => $sub) {
$message = str_replace('{' . $var . '}', is_object($sub) ? $sub->evaluate() : $sub, $message);
$message = str_replace('{' . $var . '*}', escape_html(is_object($sub) ? $sub->evaluate() : $sub), $message);
}

It works, but it is sloppy. If other escapers are used it will fail, but generally it is just inelegant and comes from a much earlier time where the Tempcode engine could not do late binding.

We can do something like...

$message->singular_bind($var, $sub);

(not directly, as $message is a string currently, as we have already flattened it -- so the code needs wider restructuring to accommodate the change)
Steps to reproduce

Funded? No
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Rating

Unrated