Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Curly braces in templates

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

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

Page: 1
Go to End
Author Topic: 1441 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    Curly braces in templates Link to this post

    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?

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Curly braces in templates Link to this post

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

    1441 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.