rejetto forum

Macros

Mars · 231 · 113345

0 Members and 2 Guests are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2052
    • View Profile
a request

{{?urlvar}}  return the last url value from ?urlvar=x

when we want test the value we use  {{ {{?urlvar}} = x }}  true(1) or false(0)

i know it will be easy to concatenate it to obtain  {{?urlvar=x}} will return 0 if urlvar<>x,  and   '1' if true

{{?urlvar=}}  can give same result as  {{not|{{!urlvar}}}}

then by example

{{!sort=}} return true(1)  if sort is not in url else we must use  {{not|{{!sort}}}}
{{!sort=n}} return true(1) if sort is defined in url as  ?sort=n  , else false(0)
« Last Edit: December 16, 2007, 09:06:43 PM by mars »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
it's not a matter of sections.
SET must be before CALL in the way the final html is built.

Thats what I thought to start with, but I'm not getting anything returned when SET is in the main section or in [files] and CALL is in [folder] and [file].


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2052
    • View Profile
It is always necessary to present a part of your template to obtain a maximum of help(assistant),otherwise our understanding of your problem remains too vague


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13438
    • View Profile
Thats what I thought to start with, but I'm not getting anything returned when SET is in the main section or in [files] and CALL is in [folder] and [file].

ah, that's because the main section is parsed after the file list is built.
from next beta you can move your macros to the [special:begin] section.
this should solve your problem.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13438
    • View Profile
i know it will be easy to concatenate it to obtain  {{?urlvar=x}} will return 0 if urlvar<>x,  and   '1' if true

it will work from next beta


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
ah, that's because the main section is parsed after the file list is built.
from next beta you can move your macros to the [special:begin] section.
this should solve your problem.
Thanks rejetto. Always presumed the main section was parsed first.

When CALL and SET are documented in the wiki, it would probably be a good idea to mention that SET should be placed in [special:begin].


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2052
    • View Profile
 ??? or ;D on behalf of  rejetto

is it POSSIBLE two create four macro

{{begin  | {{onemacro}}  }}     before main

{{before | {{onemacro}}  }}     before %list%

{{after   | {{onemacro}}  }}     after  %list%

{{end    | {{onemacro}}  }}      after  main


BEGIN work as section [special:begin] : before main

BEFORE is evaluated  at the begining of %list%

AFTER  is evaluated  at the end of %list%

END  is evaluated  when all macro and symbol  above are evaluated


Application:

somewhere in template we want to set a variable

{{begin | {{set| items | 0 }}  }}


we have section folder like

[folder]
{{inc|items|1}} ......

then to reproduce the last value at begining of main page, we must  use some javascript
else we can use

{{after| {{^items}} }} and no more  %list% {{^items}}  in this order to have the correct result
 
« Last Edit: December 18, 2007, 10:36:14 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13438
    • View Profile
you can do such job with just by using [special:begin]

try the attachment and you'll see it working


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2052
    • View Profile
Already some hours ago that works

  look at the attachment


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
Can we get a macro for %new% {{if| {{is new|NEW!}} }} or something, if anyone has a better idea... Cause other than [item-archive]  and [protected], [newfile] is the only other section which only contains text for no real purpose. And also, the section name is incorrect cause %new% - [newfile] works on folders and links also...


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
To try and stay the same as the other macros, I suggest {{get|is new}}

Edit, also an option to highlight "|" in the template editor would help readability and split the macro's up into smaller segments.
Another thought, The macro engine performs the macro's from the inside outwards, so at some point it would have to pair the braces"{{}}", would it be possible to have the braces paired in the template editor, where as if you clicked on a brace it would highlight all of its contents. That would help debugging your macro's greatly.
« Last Edit: December 19, 2007, 04:13:58 AM by Foggy »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
A couple more macro suggestions :P
{{encodeURI}}
{{decodeURI}}
{{escape}}
{{unescape}}
These four would be useful to encode special characters and may help in language support.

and

{{round}}
Why have all the other math operators if you cant round your result's to X decimal places.


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
Pretty print is something i've wanted for a long time, but it is too hard apparently.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13438
    • View Profile
every decent text editor has customizable highlighting.
i know you use notepad++ (i use pspad).
start building your syntax definition for template macros, cause it won't take long till we have support for the external editor. ;)


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
Oh u mean the template will be read from the external file finally? If that is the case, I might make a user defined one for notepad++ and post it on the forum... one that shows sections, symbols, and macro's.