[Typo3-dev] Syntax / Error highlighting TypoScript
Georg Rehfeld
georg.rehfeld at gmx.de
Fri Apr 9 04:24:17 CEST 2004
Dear all,
beeing with the Typo3 community since more than 4 weeks, mostly silent,
learning a lot and still considering me a newbie I attempt to suggest
a new feature:
Highlighting TypoScript errors.
As far as I could figure there is some rudimentary indication of ignored
Typoscript (e.g whitespace), but obvious errors in Typoscript are shown
nowhere. For instance, if I write something like:
config.this_is_my_crap = 4711
or
styles.content.lastUpdate {
data_this_is_more_personal_crap = page:lastUpdated
}
this is simply accepted, as it is syntactically correct - but
semantically it makes no sense: there isn't any "...crap" property
available in the "styles.content.lastUpdate" object (whatever it is
actually). And at runtime: the site using such a template simply
"does not work as expected" (see the endless similar questions on
the user list and consider the big, big efforts of the supporters,
having to explain over and over e.g. '<whatever> has no stdWrap' or
'try this code' ...).
My suggestion boiles down to checking ALL Typoscript objects/properties
against the PHP classes that are expected to do some work with these
properties at _compiletime_ instead of simply failing without notice
at _runtime_ .
I think, there is no _compiletime_ in the common (developer) sense in
Typo3, when things are serialized it is often at _runtime_ , isn't it?.
Error messages in the "frontend" ain't acceptable most often (they would
hit end users). And it would be contra productive to interrupt the
saving of TS code with more or less picky messages in the backend.
So I suggest to offer this new feature at the same place as the current
rudimentary support: the "Template Analyzer". Maybe only on explicit
request.
As far as I can see currently this feature would require major changes
in all and every Typo3 PHP class:
- every class had to _register_ it's allowed properties somewhere.
- every class had to have a _ListProperties()_ method, giving back
all registered (usable) properties, probably accompanied by the
datatype requiered, implemented to enumerate the properties
of sub-objects by delegation.
- every class had to _ignore_ any property not registered to
avoid 'secrets'
- the Template Analyzer had to call the ListProperties() method on
every top level object and compare to the TS given, highlighting
unknown properties/objects.
Please understand: this as a Request For Comment only. I'm not a
compiler expert at all, my suggestion only would give "unknown
property 'xyz' at line 123/near <whatever>" messages and no clue
about how to fix the error.
Still I think this would be a big step towards usability of Typo3
(at least for newbies, but saving time for experts too).
Besides: I think, some of the neccessary code can easily be implemented
in some common base class and the backend could easily be configured to
not call classes, that violate the contract.
What do you think?
(And, please, don't flame me too hard, if my suggestion already is
available somehow in Typo3 and I'm only missing some point again.
Then, please, point me in the right direction, and raise that document
into the FAQ, e.g. 'HOW TO DEBUG TypoScript').
best regards, thanks for your time and comments
Georg (aka xlerb)
--
___ ___
| + | |__ Georg Rehfeld Woltmanstr. 12 20097 Hamburg
|_|_\ |___ georg.rehfeld.nospam at gmx.de +49 (40) 23 53 27 10
More information about the TYPO3-dev
mailing list