 
   appendTemplateIntoPubFile: ->
     template = fs.readFileSync(@templatePath, {encoding: "utf-8"})
+    template = @renameTemplateVariables(template)
     fs.appendFileSync(@fullFilePath, template)
 
-  renameTemplateVariables: ->
-
+  # returns transformed {String}
+  renameTemplateVariables: (tmpl) ->
+    tmplString = transformVariables(@resName, tmpl)
+    tmplString = tmplString.replace('__pub-name__', @pubName)
 
   # find the filename and publication name
   parseParams:(params) ->

      @printBadSynaxHelp()
      process.exit(1)
    else
      return {filenameRoot: matches[1], pubName: matches[2]}

  printBadSynaxHelp: ->
    puts "\nBad Publish Name Syntax, see mgen publish --help"

    @opts = opts
    @ext = '.js'
    params = @parseParams(pubParams)
    @filename = params.resourceName + @ext
    @pubName = params.pubName
    @resName = params.resourceName
    @pubsPath = "server/publications/"
    @fullFilePath = @pubsPath + @filename
    @templatePath = "#{templatePath}publish/publish" + @ext

    @createPublicationFile()
    @appendTemplateIntoPubFile()
    puts "Inserted '#{@pubName}' into #{@fullFilePath}"

  # private
