Dreamweaver Commands Question

Does anyone know how to write a command that will write a portion of code to an html document?

I have a command written that will create x number of html pages from a ‘template’. It basically just copys and pastes the ‘template’ file using a dynamic name generated from a for loop.

What I would like it to do, is then take the same variable it uses to generate the name, and write a section of code in the <head> that looks like this, where ‘z’ is the dynamic variable generated from the loop:

<script type"text/javascript">
var lesson = 'z'
</script>

it seems like i can only find scripting that will allow me to create actual content in the body, i.e.:

dw.getDocumentDOM().insertText('xxx');

anyway to get it to write code?

thanks.
David