Re: [Request for feature] Problem with ClearSilver syntax
"Léo Gillot-Lamure" <[email protected]> Fri, 29 Aug 2008 21:59:05 +0200
| Newsgroups | gmane.text.clearsilver.general |
|---|---|
| Message-ID | <[email protected]> |
2008/8/29 Brandon Long <[email protected]>: > 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? > I don't know about standard HTML editors like Nvu because I'm using an XML editor, but my documents must be pure XML. >> 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") ?> > Mmh, it could be a temporary solutions, but it would break the XML's tree model : instead of something hierarchically *in* an element, you have something enclosed by PIs, at the same level than the parent element, this is semantically bad :/ . > >> - 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. > I 'm (re)looking at that (and this C code seriously hurts the eyes of a java programmer ^^), but it's very complicated : there seams to be more than one reference to '<' (and '>') in the code. I would simply need to change them to '(' and ')', for example... I will tell here my results. > Brandon > -- > "Look, all that matters in a relationship is that you like the > same pizza toppings." -- Daria, "Sappy Anniversary" 2/26/2001 > Thanks, Léo Gillot-Lamure.