[TYPO3-dev] Coding Guidelines for TypoScript

Jigal van Hemert jigal at xs4all.nl
Sat Aug 14 15:43:41 CEST 2010


Hi,

On 14-8-2010 12:05, Sebastian Michaelsen wrote:
> Should we add some rules for TypoScript to the CGL? css_styles_content
> has a lot of TS, it would be good to have it consistent.

Hard to make easy to follow "rules" to improve readability.
If we have "rules" t3editor would need a 'reformat' button to fix the 
code again after editing it.

> Here is how I try to keep my TS consistent and good readable:
>
> 1. When to use Brackets
> Use a Bracket whereever you would otherwise have 3 successive lines of
> "objectpath."
>
> # "HTMLparser" does not need an indented block, because only 2 properties
> # of it are used. When removing the block, you'll get 3 times
> # "nonTypoTagStdWrap."
> # which needs an indentation then.
> lib.parseFunc_RTE {
>   nonTypoTagStdWrap {
>     HTMLparser = 1
>     HTMLparser.keepNonMatchedTags = 1
>     HTMLparser.htmlSpecialChars = 2
>   }
> }

lib.parseFunc_RTE doesn't have more than 2 properties, so

lib.parseFunc_RTE.nonTypoTagStdWrap {
   HTMLparser = 1
   HTMLparser.keepNonMatchedTags = 1
   HTMLparser.htmlSpecialChars = 2
}

would be the preferred version?

Or

lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser = 1
lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser {
   keepNonMatchedTags = 1
   htmlSpecialChars = 2
}

See how hard it is to make clear rules? :-)

> 2. Brackets and Whitespace

+1

> 3. Order of stdWrap properties
> When using stdWrap properties they should be ordered like they are
> executed. When you write your TS, you have to be aware of this anyway.

Well, in many cases the order goes kind of automatic, or you group the 
properties in an order which is logical to you (functionality wise). 
Again, this could be a nice task for the editor tool to do.

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list