Skip to content

Support custom placeholders #10

@project-repo

Description

@project-repo

Hi,
I started using this plugin today for a note-taking system for my upcoming studies and I think it has proven to be very helpful. Thanks!
However, I noticed that it would be very practicle to be able to define custom placeholders since I use a system where I prompt the user to input values for certain placeholders (maybe, if you want, I could open a separate issue for supporting user input for undefined fields) and some of the things I would like to input do not exist (e.g. Chapter titles, files to include, etc.).

I circumvented this by writing a short function which parses the variable g:tmpl_custom_placeholder (defined as a dictionary, e.g: let g:tmpl_custom_placeholders = {"TEST": "answer"}) and replaces for example {{TEST}} with answer.

This is the function I added to plugin/templates.vim:

function <SID>ExpandCustomTemplates()
    if exists('g:tmpl_custom_placeholders')
        for [key, value] in items(g:tmpl_custom_placeholders)
            call <SID>ExpandTemplate(key, value)
        endfor
    endif
endfunction

I'm open to suggestions on how to improve this. What do you think?

cheers,
project-repo

https://app.leanboard.io/board/89f103e3-2942-40a0-ba45-26dc0be9e52a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions