Sorry, if this has already been posted/suggested...
Using chunks for TinyMCE templates keeps all the templating in the site manager for easy maintenance. TinyMCE templates make it easy to allow insertion of divs and spans in a consistent manner by content editors.
Create a new resource/web page with the alias "getchunk", no template and the content:
Create a snippet called GetChunk with:
<?php
// get chunk name
$name = isset ($name) ? $name : strip_tags(stripslashes($_GET['name']));
// get chunk
$output = $modx->getChunk($name);
return $output;
?>
Go to the configuration options for TinyMCE plugin and add "template" to Web Plugins and one of the button rows. Select the "custom" theme.
Note from sharkbait: you also need to do this under Configuration -> Interface
In the TinyMCE plugin custom parameters field add:
template_external_list_url: "/templates.js"
Create a new resource and set the content type to "text/javascript" and the alias to "templates.js". Disable TinyMCE for editing this document. Remove the template selection. Enter:
var tinyMCETemplateList = [
// Name, URL, Description
["Test Template", "/getchunk.html&name=test-template", "A template for testing"]
];
Create a new chunk called "test-template" with some HTML.
Now you should be able to choose "Test Template" in the templates list in TinyMCE. When selected it will insert the contents of the "test-template" chunk.
Optional: it should be possible to have templates.js call a snippet that automatically builds the javascript template list from a set of chunks, perhaps with a specific prefix. This is left as an exercise for the reader.
Andy