Well, the problem is that JavaScript doesn't really have any way to output things without using some element already on the DOM.
setup.chat = function () {
var args = [].slice.call(arguments);
var name = args.shift();
return name + ':\n' + args.join('\n');
};
Edit: Fixed an error (forgot to invoke the shift method).
This function will work as a helper function for <<print>>:
<<print setup.chat('name', 'line1', 'line2', 'etc...')>>
We need the return because we need some type of value to be sent to print.
Without a return, we need to do more work; we need to create an element on the page and pass that element to the function:
setup.chat = function () {
var args = [].slice.call(arguments);
var name = args.shift();
var $el = $(args.shift());
var str = name + ':\n' + args.join('\n');
$el.wiki(str);
};
Then, in passage:
@@#chat;@@\
<<run setup.chat('name', '#chat', 'list of lines')>>
That's more work.
We don't really need a function at all though. We could just use a widget.
<<widget 'chat'>>
<<set _name to $args.shift()>>
<<print _name + ':\n' + $args.join('\n')>>
<</widget>>
Usage:
<<chat 'name' 'line1' 'line2' 'etc...'>>
Overall, I believe the least efficient way to get what you want is with a function that returns nothing.
I didn't test this code, let me know if you encounter any errors.
Edit: I'll see if I can whip something up that's closer to the chat feature you describe later, when I have more time.