<commit_before>let s:templates_parsers = {
    \ "CURRENT_FILE": "templates#parser#CurrentFile",
    \ "CURRENT_TIME": "templates#parser#CurrentTime"
    \ }

function! s:ParseCommand(parser_name)
    echom a:parser_name
    if has_key(g:templates_custom_parsers, a:parser_name)
        let l:func = g:templates_custom_parsers[a:parser_name]
    elseif has_key(s:templates_parsers, a:parser_name)
        let l:func = s:templates_parsers[a:parser_name]
    else
        return a:parser_name
    endif

    return function(l:func)()
endfunction

function! templates#AddFileTemplate()
    let l:template_file = g:templates_folder . &filetype . '.template'
    let l:writecmd = '0read ' . l:template_file
    silent! execute l:writecmd

    let l:exec_line = '1,' . line('$')
    let l:eval_regex = g:templates_exec_start . '(.+)'. g:templates_exec_end
    let l:eval_func = '\=s:ParseCommand(submatch(1))'<commit_msg>Modify, support use function arguments.<commit_after>let s:templates_parsers = {
    \ "CURRENT_FILE": "templates#parser#CurrentFile",
    \ "CURRENT_TIME": "templates#parser#CurrentTime"
    \ }

function! s:ParseCommand(parser_args)
    let l:parser_args = split(a:parser_args, '|')
    let l:func_name = l:parser_args[0]
    let l:func_args = l:parser_args[1:]

    if has_key(g:templates_custom_parsers, l:func_name)
        let l:func = g:templates_custom_parsers[l:func_name]
    elseif has_key(s:templates_parsers, l:func_name)
        let l:func = s:templates_parsers[l:func_name]
    else
        return l:func_name
    endif

    return function(l:func, l:func_args)()
endfunction

function! templates#AddFileTemplate()
    let l:template_file = g:templates_folder . &filetype . '.template'
    let l:writecmd = '0read ' . l:template_file
    silent! execute l:writecmd

    let l:exec_line = '1,' . line('$')
    let l:eval_regex = g:templates_exec_start . '(.+)'. g:templates_exec_end
    let l:eval_func = '\=s:ParseCommand(submatch(1))'
{'fraction_non_alphanumeric': 0.1267175572519084, 'fraction_numerical': 0.004071246819338422, 'mean_word_length': 4.270777479892762, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720882', 'n_tokens_mistral': 695, 'n_tokens_neox': 685, 'n_words': 119}