From: Tavis R. <ta...@ca...> - 2001-04-25 00:20:02
|
Hi, I've basically finished it. A few stylistic details and lot of testing remain. http://www.calrudd.com/templates-dev.tar.gz I settled on \n or ;# for closures. So #if 1 and #if 1 ;# are the same thing. For implementation reasons the explicit closure must consist of 2 chars. other changes: - $ is not used when declaring vars, as in shell languages, so #for $i in $list ;# should be #for i in $list ;# This makes the implementation much simpler!!!! - ## is now a single line comment - <# for multiline comments #> - #else if 1 ;# works #elif 1 ;# doesn't! - blocks are closed with #endif #endfor or #endmacro, not #end! - $*var will cache the var (was $var* yesterday) - $*15*var will recache every 15 min Try it out and let me know if it crashes or how it can be improved. Cheers, Tavis Checklist ================= $varname - tick ${varname}aoeuoeau - tick $object.method - tick $object.method() - tick $object.method('arg1', 'arg2') - tick $object.method($anotherVar) - tick $object.method(kw1=1234) - tick $object.method(kw1=$anotherVar) - tick $object.method($anotherVar*2) - tick $object.method($anotherVar[5:15]) - tick $!varname - not yet - this is the default behaviour for $varname, but I can change this easily #if $test ;# ... #endif -tick #if $test ;# ... #else ... #endif -tick #if $test ;# ... #else if $anotherTest ;# ... #endif -tick #for(i in $list) ... $i ... #endfor - tick (no $ for initial assignment - like in sh) #for i in range(50) ;# $i #endfor - tick - directives are nestable of course #parse(file="abspath") - tick #parse(file="relpath") - not yet with Webware contexts #parse($varname) - tick - it parses the value of $varname #include(...) - tick #set(...) - tick #macro(arg1, arg2=1234) #endmacro - tick #stop ... #restart -tick ## comment - tick + <# multiline comment #> ++++ PLUS ++++ - plugin-supporting parser that can handle user-definded taglibs. Multiple delimeter sets can be used - $vars are processed with NameMapper so it's very flexible and namespaces can be stacked if you want (i.e. pluggable code libraries are already possible). - can also handle PSP code (<% %>, <%= %>), if this option is explicitly turned on (not a good design idea, so it's turned off by default) - dead-simple cache handling: $*cachedVar - tick (can be recached programmatically) $*15*timedRecacheVar - tick (recaches every 15 minutes) $*1.5*timedRecacheVar- tick (recaches every 1.5 minutes) - templates are nestable -if $var maps to an object that inherits from TemplateServer.Plugin then the transaction object is automatically passed to $var each time it is called. This allows plugins to interact with sessions, cookies, fields, etc. in a black-box fashion (like COM components in ASP). - TemplateServer follows the Model-View-Controller paradigm, but is set-up so the 'Controller' (i.e. intances of TemplateServer) can be used either as as webware servlet or as a command-line tool, with no changes to the code neccessary. - When run from the command-line TemplateServer provides a number of introspection tools that could be very useful for debugging. |