-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any way to template new wiki pages? #46
Comments
Hi! Sorry for the delayed response; I've been mostly away from my computer during the Christmas break. Thanks for raising the issue and giving a good description of what you want. This is not possible at the moment, but it should be a relatively simple feature to implement, and I'll look into it with the new year. Do you have an idea of how you would want to configure such a feature? I could think of some alternatives, e.g.: " String based template
let g:wiki_template_new = '# {pagename}'
" Function based template
let g:wiki_template_new = 'MyTemplate'
function! MyTemplate()
return join([
\ '# ' . expand('%:h'),
\ '',
\ 'Some text here.',
\], "\n") . "\n"
endfunction I think I prefer the last method, but it might be too complicated for a lot of people. If I implemented the function based feature, then I could also implement the string based version on top of it afterwards. |
I would think a file-based method would be best actually. the var would point to a file that would have (for example):
And it would read that and transform the variables appropriately: This is all hasty pseudo-code of course, but it lays out an idea of what I think would work best for sure. Gives the control of the function method, with almost no changes from normal markdown. EDIT: A suggested default value for the file would be
|
Ok, we could use a file based template. But to avoid a lot of future issues, I would want to make a good specification first. Here is a first draft: Option Template format
The function expansions allow one to easily write something like your Example g:wiki_page_templates = ['.wikitemplate', '/.wikitemplate']
function! WikiTemplateSection(ctx) abort
if !empty(a:ctx.pagetarget)
return [
\ '## ' . a:ctx.pagetarget,
\ '',
\]
else
return []
endif
endfunction The template: # {pagetitle}
created: {date} {time}
{{WikiTemplateSection}} I'll update the specification based on the discussion, and when we agree I'll begin to implement it. The most crucial thing is to decide on a good structure. If we do that well, then it will be easy to improve and extend the feature in the future if necessary. |
I've used snippets (e.g. Ultisnips) with dates and other types of information to quickly load a template for new journal entries and reference-"cards" for academic papers. In that case you open a new file, type a couple of chars e.g. From
|
I think @gauteh has a point here: Templates like what you ask for, @Corey-Keller, could easily be implemented as snippets with e.g. Ultisnips. This would have the benefit of relying on a well tested plugin which may be used for many things. One may also use automatically expanded snippets, e.g. say a snippet where I'm curious, @Corey-Keller, do you still think the template feature would be interesting, given that one could quite easily use snippets for this? |
Yes, it is still useful. For a couple of reasons:
From a user standpoint that's a LOT more difficult than making a file with a few template sections in it. |
Great, thanks for providing some good arguments for your case, in particular I think the number 2 is important. So, I would still like feedback on my proposal for the specification of this feature, see my earlier comment. If you think it is already acceptable, then I'll try to implement it when I get the time. |
I have an example to make sure that I understand the proposed spec. If I have:
The sections would be:
Is that correct? If so, that seems to be a good solution. Although, if the description is empty, how should the title be decided? It's obvious if the link is This is kind of a separate request, but it would be good to have |
Sorry for taking so long! It's been a very busy month!
I would say But these are all details that we may settle and improve on later. Regarding case styles, I think we could allow for a modifier to define case style. I also think we should keep the case of the original text by default. I suggest we allow something like this:
This will be replaced with the result of FunctionName(Argument1, Argument2, ...) Now you could ensure case title by defining a function
Perhaps some common functions should be available, e.g. I'll begin to work on this when there is time. |
Hi, I've started using the following to get a very simple template going for my journal entries (separate file for each day):
|
Again, sorry for the delay. At least, now I have started. I've typed out the specification in the docs. I would be very happy to get some feedback/comments, see #83 for details. As I've opened a PR for resolving this issue, I think it is convenient to close the issue and continue the discussion in the PR thread. |
It's very possible that this is already a feature, and I just don't realize it, but is there any way to set up the default for new pages? For example, I turn the text "Example Page Here" into a link, and open it.
Observed behavior: empty document
Expected behavior: A document starting with a level 1 heading containing the name of the link, and maybe a few new lines. Ideally, it would all be configurable beyond that, but that seems like a solid minimal default.
The text was updated successfully, but these errors were encountered: