How to render template in dataviewjs

What I’m trying to do

For example, I have a dataviewjs code like this:

// dataview js block
function render(year, month){
// In this function, I want to render a new file and
// I want to make its frontmatter based on the 'year' and 'month'
// which are the params of this function

const {createButton} = app.plugins.plugins["buttons"]
const tableData = []
        el: this.container, 
        args: {name:  "Jan"}, 
        clickOverride: {click: render, params: [2023, "Jan"]}
dv.table(["button","month"], tableData)

When I click the button, a new file depending on ‘year’, ‘month’ and a custom template should be created.

template is like this:

- total
- month
year: <% year %>
month: <% month %>
await forceLoadCustomJS()
const { DataviewUtils: utils } = customJS
const today ="now")

utils.renderMonthDetail(dv, dv.current()["year"], dv.current()["month"])