Re: name:variable

Sovande Ulv <[email protected]>
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
On Nov 29, 2007, at 4:18 AM, Brandon Long wrote:

> Yeah, I don't think this is going to work.
>
> For instance, this expression won't work:
> <?cs var:url_escape(Request.Header.Accept-Encoding) ?>
>
> Even if we did the lookup in parse_expr instead, you'd get confusing
> results based on wether or not Request.Header.Accept-Encoding existed.

Agree, the patch was too simple and handled just one case. Just to  
prove that it is possible to do this general, enclosed a new patch  
which extend a simple branch in parse_tokens() to do a quick sub- 
scanning of input and do the HDF lookup. The new patch will handle  
compound statements such as <?cs var:url_escape(Request.Header.Accept- 
Encoding) ?>  etc.

I wont ask for acceptance of this patch because it just address my  
special case with HDF variables containing '-' in them, and should not  
be included in ClearSilver proper. However, if anything, what you may  
take away from the patch is to use a bit of table-driven lookup and  
save all those function calls to strpbrk() in csparse.c.

> Plus, HDF variable name lookups aren't the fastest things.  Also, this
> adds yet another place where vars have to exist at parse time.
>
> And I just don't think its that hard to not have vars with +/- in  
> them.
>
> CGI just munges Accept-Encoding to Accept_Encoding, the C++ wrapper I
> use at Google just munges it to AcceptEncoding, and I should probably
> just add that code to the cgi wrapper in ClearSilver.

Ah well, I think I have to revert to this then.

> Also, I'm pretty sure this works if you have to have these types of  
> var
> names:
>
> <?cs var:url_escape(Request.Header["Accept-Encoding"]) ?>

Yes, just verified, it works fine. Apropos, speaking about fine, I  
must say, now that I finally have taken a closer look at the  
clearsilver parse code, that it is very nice and clever indeed.

Best Regards
patch (application/octet-stream, 1.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.