$modx->getChunk('ChunkName',$options);$chunk = $modx->newObject('modChunk');
$chunk->setCacheable(false);
$chunk->setContent($string);
$chunk->process($options);
I can write a function to do this, but wanted to know if there was an already-existing method that I could use. I see how the method you offered below works (creating a new chunk...) ... should I assume that it’s a more resource-intensive solution than writing a small function to parse the placeholders?
I think it would be less efficient to roll your own. modChunk is always loaded as a class, and once a Resource is cached, the Chunk source are also cached along with it (in 2.1+), making it very fast to parse. I would use a blank modChunk, and call process($properties, $content) if you want to process your content from external files. There is no real overhead associated with using an instance of modChunk. There is with loading your own code to parse things in a non-standard way. You can also look at the modChunk->process() method if you want to see how things are processed.
Rolling your own would almost certainly be more efficient, but the difference might not be noticeable, depending on how often it happens.
There may be a way to use the parser for this, but I don’t know offhand what the method would be.

$tpl = 'My formatting string contains placeholders for [[+cat]], [[+dog]], and [[+chimp]]';
$props = array('cat'=>'Meow', 'dog'=>'Woof', 'chimp'=>'AAAAAA');
$uniqid = uniqid();
$chunk = $modx->newObject('modChunk', array('name' => "{tmp}-{$uniqid}"));
$chunk->setCacheable(false);
$output = $chunk->process($props, $tpl);
It should be clarified that the placeholders corresponding to the $props must use the "+" notation. Here's a bit of code inspired by the getResources snippet:
$tpl = 'My formatting string contains placeholders for [[+cat]], [[+dog]], and [[+chimp]]'; $props = array('cat'=>'Meow', 'dog'=>'Woof', 'chimp'=>'AAAAAA'); $uniqid = uniqid(); $chunk = $modx->newObject('modChunk', array('name' => "{tmp}-{$uniqid}")); $chunk->setCacheable(false); $output = $chunk->process($props, $tpl);