Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Curly braces in templates


Reply


2 Posts   1537 Views

Avatar
xmedeko

Community Member, 94 Posts

13 August 2007 at 1:55pm

Edited: 13/08/2007 2:00pm

Hi,
i have in my template: {$Date.Format(l Y/m/d)}, and the result is: {$Monday 2007/08/13}
I.e. the curly braces are in the output as well. I have noticed, each non-curly-braced replacement has a curly-braced replacement, except one, in SSViewer.php, so I have added this missing one:

--- SSViewer.php.orig   2007-07-31 09:40:06.000000000 +1200
+++ SSViewer.php   2007-08-13 13:48:43.000000000 +1200
@@ -195,6 +195,7 @@
         '/{\\$([A-Za-z_][A-Za-z0-9_]*)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",null,true)->XML_val("\\2",null,true) ?>',
         '/{\\$([A-Za-z_][A-Za-z0-9_]*)}/' => '<?= {dlr}item->XML_val("\\1",null,true) ?>\\2',

+         '/{\\$([A-Za-z_][A-Za-z0-9_]*)\\.([A-Za-z0-9_]+)\\(([^),]+)\\)}/' => '<?= {dlr}item->obj("\\1")->XML_val("\\2",array("\\3"),true) ?>\\4',
         '/\\$([A-Za-z_][A-Za-z0-9_]*)\\.([A-Za-z0-9_]+)\\(([^),]+)\\)([^A-Za-z0-9]|$)/' => '<?= {dlr}item->obj("\\1")->XML_val("\\2",array("\\3"),true) ?>\\4',

         '/\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)([^A-Za-z0-9]|$)/' => '<?= {dlr}item->XML_val("\\1",array("\\2","\\3"),true) ?>\\4',

Btw. A comma in the argument: $Date.Format(l, Y/m/d)
causes an error. Is there any way, how to put the comma in the argument?

Btw2. Isn't this regexp replacing in the SSViewer a little bit complicated? What about some simple LL/LR parser?

Avatar
Sam

Administrator, 685 Posts

14 August 2007 at 11:28am

Yeah, the reg-exp parser just kind of grew out of all proportion; a better parser needs to be made ;-)