#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".


Comments
\{+START,IF_NON_EMPTY,{unsub_url}\}
-------------------------
[font size="0.8"]\{$?,\{$IS_EMPTY,\{member_id\}\},\{!NEWSLETTER_UNSUBSCRIBE_NEWSLETTER,\{unsub_url\}\},\{!NEWSLETTER_UNSUBSCRIBE_MEMBER,\{unsub_url\}\}\}[/font]
\{+END\}
Hopefully our implementation of binding will be Comcode-safe. Comcode will recognise the use of parameters and include these as unbound within generated Tempcode -- allowing binding later.
This likely will require some deep changes in Comcode.
The processing flow has been completely refactored, it's a lot cleaner now.
My last note about Comcode doesn't apply with the new processing flow - Comcode applies last, after a separate Tempcode parse and bind.