Thanks for your work, rejetto and mars !
before entering to concrete macros, some general points to think about:
1. Security of execution: As the number of macros grow and their use will be growing, the possibility of hard to find errors increases. This means that the implementation in the delphi source should do some error checking, allowing a message where or what kind of error ocurred. For this, y suggest to include in the generated page some <p style="display:none" >{{ macro error and/or expanded macro }}</p> This could probably be switched on or off with a pseudomacro: {{debug | 1 }} . Not present: Search error by beating your head against the monitor. debug 1: see errormessage or offending expression. debug 2: see full expanded macro
2. Probably it would make reading more clear if macro names would not contain spaces:
: if not --> ifnot
: is substring -> issubstring
: file size --> filesize,
this makes reading of foreign template more simple, nobody would look for macrodefinitions like is,if,file,size,substring(this one already has confusion implementated, as macro substring exists!)
Macro 'define':
This macro is a real macro for the macro-'language', it must never be evaluated!
but i think it should not be overloaded and its definition should contain the exact number of parameters, that could be instead $n any meaningfull combination of caracteres to make it more understandable. This would also allow to check for errors if the numbers of parameters is not correct, when the definition should be applied.
{{ define | {{left | string | count } | {{ cut {{ 0 | count |string }}}}}}
then when parsing the tpl '{{ left ' is found it should be substituted by the second expression of define, applying by the way the substitution of the named parameters. When this is done, evaluation can begin.
by the way: it would be nice (because simpler to understand) to use in the wiki instead of A B C ... meaningful things:
issubstring | sample | string
cut | start | count | string .....
Namespace to use by macros:
I think there is no need to use another special caracter. But the namespace could hold an atribute-flag: 1-intrinsic macro definition 2-user definition of macro (define) 3-user set-alias macro.
If we establish some rules (all intrinsic functions are lowercase) the templatewriter can use a naming-scheme or use uppercase to distinguish intrinsic an userdefinded functions/macros.
I would propose set(preferable) or alias for inmediate execution
an define as definition, with no execution, only used to be substituted with executable macros.
« Last Edit: December 13, 2007, 12:29:20 AM by bacter »
your computer has no brain - use your own !