Skip to content
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

Includes with parameters? #31

Closed
lunacookies opened this issue Jul 9, 2020 · 4 comments
Closed

Includes with parameters? #31

lunacookies opened this issue Jul 9, 2020 · 4 comments

Comments

@lunacookies
Copy link
Contributor

lunacookies commented Jul 9, 2020

Hi,

I recently found myself in a situation in which I needed to pass parameters to an Included template that contained an auxfile block. When built with colour scheme a, I wanted @guired to be used in a particular place in this auxfile. However, when built with colour scheme b, @guired should be replaced with @guigreen. In other words, I need some way to vary a small portion of the contents of an auxfile/Include.

@lunacookies
Copy link
Contributor Author

lunacookies commented Jul 9, 2020

Here’s an example syntax:

# _statement.colortemplate
Params: fg bg style warningColor
Statement $fg $bg $style
#let g:warningColor = '$warningColor'
# one.colortemplate

Color: red #ff0000 ~
Color: blue #0000ff ~
Color: black #000000 ~

Include: _statement blue black bold @guired
# which expands to
Statement blue black bold
#let g:warningColor = '#ff0000'
# two.colortemplate

Color: orange #ffaa00
Color: pink #ff00ff ~
Color: black #ffffff ~

Include: _statement pink none italic orange
# which expands to
Statement pink none italic
#let g:warningColor = '#ffaa00'

@lifepillar
Copy link
Owner

You may deal with duplication in your auxiliary files by using multiple auxfile blocks with the same path: the blocks are concatenated in the order in which they are encountered during parsing. For instance:

# _aux.colortemplate
auxfile foo.vim
" Text common to all versions of foo.vim
endauxfile
# one.colortemplate
auxfile foo.vim
" Text specific to one.colortemplate
endauxfile
Include: _aux.colortemplate
auxfile foo.vim
" More text specific to one.colortemplate
endauxfile
# two.colortemplate
auxfile foo.vim
" Text specific to two.colortemplate
endauxfile
Include: _aux.colortemplate
auxfile foo.vim
" More text specific to two.colortemplate
endauxfile

Does that help?

@lunacookies
Copy link
Contributor Author

Yep, that completely solves it; thanks for the hint. For future reference, is this mentioned in the documentation anywhere?

@lifepillar
Copy link
Owner

No, I will document that.

lifepillar added a commit that referenced this issue Jul 11, 2020
Improve the documentation by clarifying that an auxiliary file may be
defined in multiple auxfile blocks all referring to the same path.

Addresses a shortcoming of the documentation emerged in:

#31.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants