One problem of the parser implementation is inability to add parsed text
into another variable. Command does not return a result and immediately
sends it to the stdout. Can we somehow change it?
04.07.2013 17:37, Massimo Manghi пишет:
Rivet 'parse' command has a very good and clean implementation caching
its results internally and using the full path to a file as a lookup key
in the cache. The file system time stamps tells mod_rivet when a cache
entry need refresh.
Thus the restriction with 'parse' is the templates have to be stored on
the file system, whereas Web applications today may store data (also
templates, why not?) to several classes of data sources, including
Sql/noSql DBMS, sockets, web services etc.. Thus templates could be
accessible as string stored in Tcl variables without an immediate way to
represent and locate them as file system resources (of course you might
want to implement one)
I added in trunk a simple and harmless implementation of a command
parsing a string stored in a Tcl_Obj. It's simple because based on the
code already available for parse, harmless because at the cost of having
a slightly larger module the few lines of code taken from
Rivet_ParseExecFile were replicated in a Rivet_ParseExecString function
so to avoid side effects to parse. If this command will receive your
approval it could evolve and be integrated with its file based counterpart
To test the implementation I made it accessible through the Tcl command
'parsestr'. Admittedly the name is a bad one and I don't stick to it.
Perhaps adding the -string switch to command 'parse' would be a better
choice, something like
parse -string $template
as opposed to the usual
parse <filename>
Command 'parsestr' doesn't cache the template leaving to the caller (the
application) the task to devise a possible way to cache it consistently,
when needed.
--
With best regards,
Kirill
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscr...@tcl.apache.org
For additional commands, e-mail: rivet-dev-h...@tcl.apache.org