Re: [Request for feature] Problem with ClearSilver syntax

Brandon Long <[email protected]> Thu, 28 Aug 2008 15:36:12 -0700
Newsgroups gmane.text.clearsilver.general
Organization Fiction L Networks
Message-ID <20080828223612.GA8632@bl1>
On 08/28/08 Léo Gillot-Lamure uttered the following other thing:
> Hello.
> 
> I'm using ClearSilver within XML documents, and it makes a problem :
> CS uses XML's processing instructions, and these are illegal in
> attributes (<a href="<?cs var:item.url ?>"> is not well-formed). It's
> problematic in many cases : XML and XHTML tools (editors, WYSIWYGs...)
> have an undefined (and often bad) behaviour (so it's not good for web
> designers), and stuff like XSLT or DOM libs make a fatal error.

Yeah, that's true.  Though, lots of HTML tools should understand php and
other syntax that would work... I guess not for XHTML though?
 
> Two solutions would be possible :
> - Having a syntax like <a><?cs attr:href=var:item.url ?>A link</a>
> (which would make <a href="(value of item.url)">A link</a>), but it's
> probably too complicated, and not in the logic of CS.

CS is actually agnostic to the template language, making something like
that that was so specific to XML/HTML wouldn't really fit.  You could
make functions that were available to clearsilver to do that, though not
to have it "absorb" the previous <a> into it.

Something like:
<?cs var:expand_link(item.url, "A link") ?>


> - Simply be able to use something else than <? and ?> (I think this is
> not a good choice to use XML's processing instructions, this is often
> simply inherited from PHP).

The <? syntax was around even before PHP, but it does seem like an odd
choice in hindsight, but it was around before XML...

Changing clearsilver to look for something else wouldn't be that
challenging, we already made it configurable what comes after the <? (cs
is the default, but you can set it to something else with
Config.TagStart).  The code is in cs/csparse.c:find_open_delim and more
code in cs/csparse.c:cs_parse_string_internal.

Brandon
-- 
  "Look, all that matters in a relationship is that you like the 
    same pizza toppings."  -- Daria, "Sappy Anniversary"  2/26/2001