Chunks
About Chunks
Chunks are blocks of HTML. They can only contain HTML. This way you can write whole blocks of HTML code without cluttering up your templates with HTML you'd rather keep separate. Using the multiple pass processing, you can decide which Chunks should be included in the page using snippets.
Chunks are also useful for storing blocks of HTML that you want to include in a snippet. This allows customisation of a snippet's presentation without having to modify the snippet code, allowing snippet users (rather than authors) more scope for modifying the output to their needs.
Of course HTML can also contain javascript, so you can store your javascript in a chunk too. Much easier than trying to write a piece of javascript in the middle of a piece of PHP code, and making sure all your quotes correctly match and have the effect you want. (It also allows you to include the javascript while developing and testing, and then move the actual script to an include once it all works.)
Creating Chunks
Chunks are created by simply writing HTML. You can do this in any editor you choose, or you can do it directly in the managers "Create/ edit chunk" text area box. If you use another editor, just copy your code and paste it in this box. Be sure to give your chunk a descriptive name and optionally, a description. (Description is recommended as you may forget exactly what it is at a later time.)
Putting Your Chunk in a Template
Chunks are inserted into your template by simply using this syntax:
{{ChunkName}}
Where "ChunkName" is the name you gave the chunk when you created it. (Capitalisation matters!)
The use of chunks reduces the amount of repeating text that needs to be put into a template, helping to show the structure of the page, without the detail. In order for this to be helpful, chunks should contain properly constructed segments of HTML, that will validate without requiring a balancing chunk to close elements that remain open.
Chunks within chunks
It may seem that chunks, as they hold only HTML and have no programming capbilities cannot include other chunks. Thsi is not the case, however, as the etomite parser makes multiple passes through the output text. If you embed {{ChunkName}} in the HTML, at the next pass through the output, this will be replaced by the content of the chunk. (You can in fact similarly embed a snippet in a chunk and have it executed on the next pass of the parser.) This can be useful, for example, in building a footer for your page. If the footer is put in a chunk that is used in all page templates, then if it needs to be adjusted at some stage you only need to change it in one place, rather than in every template.