[TYPO3-50-general] [TYPO3-team-core-v5] Templating Engine

Sebastian Kurfürst sebastian at typo3.org
Wed Oct 22 16:17:12 CEST 2008


Hi Ernesto,

I think I'll answer to this mail in multiple chunks, because it's so  
much what you said here :-)

> See my answer to Karsten about that. It doesn't need to output XML  
> just
> because the template is XML. See XSLT for example. If is a very strict
> XML-templating (in fact transformation) markup, but it can generate  
> not
> only XML, but also TXT, CSV, even PDFs.
Yes, that's right. I have used this as well.
However XSLT uses a fundamentally different approach, because you  
specify the template as XSLT, and to generate some HTML for example,  
you write the main template between <xsl:template match="/">.....</ 
xsl:template> (See [2] for an example)

The approach of Smarty, PHPTal, and as well Beer3 is that you have an  
output file the way you want it, and just incrementally enhance the  
output file with additional tags/attributes.
In XSLT, you do it the other way round: You embed your output into the  
"Templating Framework"(==XSLT).

>> 2) Tool support:
> Having a DTD for invalid XML doesn't seem to be possible in my eyes.  
> If
> the template cannot even validate, how will a tool be able to apply or
> enforce a DTD?
Well, of course the tool can give you only these features if you  
yourself write an XHTML compliant template. For the way eclipse works  
with autocompletion, see below.
In the beginning, I saw as well that validation is a "must" - that is,  
it must be possible to write valid XML with it, and preferably the  
template should be validatable as well. However, there is this problem  
how we implement array-properties we still need to solve in an elegant  
way.

> I don't see the phptal problem: The few phptal tags are valid XML, and
> as long as your overall document is XHTML, all valid XHTML tags are
> available. phptal is just a namespace inside the XHTML template.
Yes, you are right that PHPTal can be perfectly validated. As stated  
in [1], it uses only some well-defined tags.

However, what I meant was something different:

For me, as an end-user using this template engine, my main concern is  
that I want autocompletion support, f.e. in Eclipse. This is archived  
by having a proper XML namespace declaration, and then eclipse loads  
the DTD automatically and gives you these tags in autocompletion,  
shows you if mandatory parameters are still missing, etc...

In case of PHPTal, if you type in tal: ,Eclipse will list you all  
tall:* attributes (there are about 7 tags in the tal: namespace I  
think). However, it does _not_ tell you what has to be inside these  
attributes because this cannot be specified in the DTD.

For example, if you take the TAL variable declaration: <span  
tal:define="global destname path/to/existing/variable" />
What this actually _means_ is something like: <tal:define  
scope="global" name="destname" value="path/to/existing/variable" /> -  
So, actually, the single tal:define attribute contains three different  
parts with a different semantics.
And for this, you can't write a DTD.

What I would like to do, is the following (assuming we need some tag  
which does a variable declaration):
<f3:variable name="destname" value="....." />
And because the "variable" is implemented as ViewHelper and has to  
declare that it needs a property "name" and a property "value", this  
will be incorporated automatically into the DTD, thus eclipse will  
tell you that once you wrote <f3:variable, this tag needs a name  
property and a value property.

(I am not yet sure if we need such "variable" support, or what the  
benefit of this would be, but I think we could easily write a view  
helper for it; But that doesn't matter for the discussion here).


>
>> However I think we still need an _alternative_ way of specifying
>> namespaces, that is, if you want to output a LaTeX template for  
>> example.
>> I just implemented the alternative first :-)
>
> Doesn't convince me as an argument not to enforce XML. There is also
> some XSLT templates to transform XML to LaTeX (see
> http://tbookdtd.sourceforge.net/). I expect the template engine also  
> to
> be able to generate LaTeX output.
Yes, the engine will as well output LaTeX - but as stated above, I  
think we cannot compare XSLT and the other templating engines because  
of really different approaches.

> For example a template to generate pages of blog entries in LaTeX  
> could
> look like that:
>
> That is a perfectly valid "XML-snippet".
Yes, However you still need some namespace declaration where you  
import your view helpers.
And if you write something like
<xml xmlns:f3='something'>
... your template code here...
</xml>,
then the <xml> tag would be included in the output as well. That's why  
IMO you need a second way to specify namespaces.

> See my reply to Karsten for
> more examples and some considerations (like stripWhitespaces or
> xmlEntitiesReplace).
Seen that, and will answer this later :-)

> This is what I love in Smarty and miss in phptal: "modifiers". So  
> cool:
>
> {$time|format_time}
>
> But I would have no problem if we just had:
>
> <f3:filter name="format_time">{time}</f3:filter>
I don't see why you don't just write a seperate tag for formatting  
time, and this could be called then like:
<f3:formatter:time value="{time}" /> or <f3:formatter:time>{time}</ 
f3:formatter:time>
or {f3:formatter:time("{time}")} (though we might need to make the  
syntax a bit prettier)

Thanks for your great arguments!

Greets,
Sebastian


[1] http://phptal.motion-twin.com/manual/en/split/ar05.html#attributes
[2] http://de.selfhtml.org/xml/darstellung/xsltbeispiele.htm#grussbeispiel
--
Gimme five!



More information about the TYPO3-project-5_0-general mailing list