[ZPT] Stylesheet Language

Tino Wildenhain tino@wildenhain.de
Tue, 07 May 2002 05:09:52 +0200


Hi,

I'm glad this idea finally made it!
Lets hope "Tassle" would not sound like "hassle" too much ;)

Are there any ideas to: clean class defining and derriving (according
to both the css-selector style and the zope/python way)?

What about a base-html-tag class to avoid constructions like 
"<b>something<b>"?
This leads to a dom approach somewhat.

Regards
Tino

--On Montag, 13. Mai 2002 09:49 -0400 Casey Duncan <casey@zope.com> wrote:

> On Friday 10 May 2002 01:39 pm, Evan Simpson allegedly wrote:
>> Thanks to Casey Duncan, I'm now thinking hard about an extension to ZPT
>> that I'm tentatively calling Template Style Sheet Language (pronounced
>> "Tassle").  Much like CSS, this would allow you to write the equivalent
>> of TAL statements out-of-line, and apply them based on tag selectors.
>
> 8^) I like the name. I'm glad this piqued your interest, I doubt I will
> have  much time to spend on it for a while.
>
>> Stylesheet sytax is much more forgiving than attribute syntax, so some
>> of the more awkward aspects of TAL could be abandoned.  For instance, we
>> can use "=" instead of "define", and we can have multiple instances of
>> the same kind of statement applied in whatever order we specify.  String
>> expressions could simply be quoted strings, and explicit expression
>> types could become pseudo-functions such as "python(<expr>)". A major
>> advantage would be the ability to attach generic code to tags based on
>> pattern matching.  This also eliminates the need to add new tags in
>> order to control scope and order of operations.
>
> A nice capability this lends you is the ability to affect structure by
> tag or  tag structure alone. For instance, you could strip all font tags
> (or change  them to spans), replace all image tags based on their src
> values, etc.
>> Here's a complex example with made-up syntax:
>>
>> <style type="text/tssl">
>>    @begin { base = template/portal_url; }
>>    .item-list {
>>      items = path-string(attrs/items);
>>      @if not(items) replace: structure "<b>No items</b>";
>>    }
>>    .item-list > * {
>>        repeat: item items;
>>        i = repeat/item/number;
>>        [name] = "item-$1";
>
> So, [name] means: set the tag attribute "name" right? What is $1? did you
> mean  $i?
>
>>    }
>>    img.portal { [src] = "$base/${attrs/src}"; }
>>    form.auto {
>>      recname = attrs/name;
>>      recpath = "$recname | options/$recname | nothing";
>>      rec = path_string(recpath);
>>    }
>>    form.auto input, select, textarea {
>>      name = attrs/name;
>>      [name] = "$recname.$name:record";
>>      value = path_string("rec/$name | nothing");
>>    }
>>    form.auto input[type=text] {
>>      [value] = value;
>>    }
>>    form.auto textarea {
>>      content: value;
>>    }
>>    form.auto option {
>>      optvalue = attrs/value;
>>      [selected] = python(value == optvalue);
>>    }
>> </style>
>
> I really like your ideas above. After a couple of reads it was pretty
> easy to  grok based on exisitng TAL idioms.
>
> [snip html]
>
>> The interaction between TAL and TSSL could be controlled by having all
>> TSSL statements for a tag execute before TAL on the tag, but providing a
>>   "@tal;" statement, so that the following:
>>
>> <style type="text/tssl">
>> * { x = "1"; @tal; y = "$z 3"; [z] = z; }
>> * { y = "2"; @tal; content: y; }
>> </style>
>
> interesting.
>
>> For documents, such as XML with a DTD, in which an inline <style> would
>> not work, we could (ab)use the standard:
>>
>> <?xml-stylesheet path="here/autoform" type="text/tssl"?>
>
> I was thinking along these lines. It should be possilbe to use linked
> style  sheets with html templates as well. I can see having a global
> style sheet  containing things useful site-wide, a more local style
> sheet, useful for a  given functional area. And then an inline style
> sheet used only by a single  template.
>
> They would cascade just like CSS does, so that local rules could augment
> or  replace more global ones.
>
> I'm pretty excited about this as a general concept. I think it really
> could  transcend traditional notions about templating. Thanks for running
> with it.
>
> -Casey
>
>
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt