Skip to content

Commit c62600a

Browse files
committed
Rename filename to file
`filename` is still available in the template rendering context.
1 parent f8d5647 commit c62600a

File tree

12 files changed

+98
-118
lines changed

12 files changed

+98
-118
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ variable. A plugin will apply a template if you add the template name to the
354354

355355
Available built in templates are
356356

357-
- **source**: source each filename in a plugin.
357+
- **source**: source each file in a plugin.
358358
- **PATH**: add the plugin directory to the `PATH` variable.
359359
- **FPATH**: add the plugin directory to the `FPATH` variable.
360360
- **path**: add the plugin directory to the `path` variable.
@@ -364,7 +364,7 @@ As template strings they could be represented like this
364364

365365
```toml
366366
[templates]
367-
source = { value = 'source "{{ filename }}"', each = true }
367+
source = { value = 'source "{{ file }}"', each = true }
368368
PATH = 'export PATH="{{ dir }}:$PATH"'
369369
FPATH = 'export FPATH="{{ dir }}:$FPATH"'
370370
path = 'path=( "{{ dir }}" $path )'
@@ -383,8 +383,8 @@ apply = ["PATH", "fpath"]
383383
```
384384

385385
The `each` value, as used in the `source` template above, specifies that the
386-
template should be applied to each matched filename for the plugin. This
387-
defaults to `false`.
386+
template should be applied to each matched file for the plugin. This defaults to
387+
`false`.
388388

389389
### Custom templates
390390

@@ -399,10 +399,9 @@ Plugins all have the following information that can be used in templates
399399
- **A directory.** In git sources this is the location of the cloned repository,
400400
for local sources, it is the directory specified. This directory can be used
401401
in templates with `{{ dir }}`.
402-
- **Zero or more filenames.** These are the matched files in the plugin
403-
directory either discovered using the the global `match` field or specified as
404-
a plugin option with `use`. These can be used in templates using `{{ filename
405-
}}`.
402+
- **Zero or more files.** These are the matched files in the plugin directory
403+
either discovered using the the global `match` field or specified as a plugin
404+
option with `use`. These can be used in templates using `{{ file }}`.
406405

407406
You can use the following global information in templates
408407

@@ -415,7 +414,7 @@ directory. We could create a new template with name **function**, like this
415414

416415
```toml
417416
[templates]
418-
function = { value = 'ln -sf "{{ filename }}" "~/.zsh/functions/{{ name }}"', each = true }
417+
function = { value = 'ln -sf "{{ file }}" "~/.zsh/functions/{{ name }}"', each = true }
419418
```
420419

421420
It can then be applied to the plugin like this

docs/plugins.example.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ apply = ["PATH", "source"]
1616
# Custom user defined templates, the `each` field means that these will be
1717
# applied for all matched files.
1818
[templates]
19-
function = { value = 'ln -sf "{{ filename }}" "{{ root }}/functions/{{ name }}"', each = true }
20-
prompt = { value = 'ln -sf "{{ filename }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
19+
function = { value = 'ln -sf "{{ file }}" "{{ root }}/functions/{{ name }}"', each = true }
20+
prompt = { value = 'ln -sf "{{ file }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
2121

2222
[plugins.async]
2323
# `github` sources provide the repository in the form {username}/{repository}.

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const GITHUB_HOST: &str = "github.com";
3333
pub struct Template {
3434
/// The actual template string.
3535
pub value: String,
36-
/// Whether this template should be applied to each filename.
36+
/// Whether this template should be applied to each file.
3737
pub each: bool,
3838
}
3939

@@ -119,7 +119,7 @@ pub struct RawPlugin {
119119
/// Which files to use in this plugin's directory. If this is `None` then
120120
/// this will figured out based on the global `matches` field.
121121
///
122-
/// These filenames can contain template parameters.
122+
/// These files can contain template parameters.
123123
#[serde(rename = "use")]
124124
pub uses: Option<Vec<String>>,
125125
/// What templates to apply to each matched file. If this is `None` then the
@@ -479,7 +479,7 @@ fn validate_template_names(
479479
}
480480

481481
impl Template {
482-
/// Set whether this `Template` should be applied to every filename.
482+
/// Set whether this `Template` should be applied to every file.
483483
pub fn each(mut self, each: bool) -> Self {
484484
self.each = each;
485485
self

src/edit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ tag = '0.1.0'
194194
apply = ["PATH", "source"]
195195
196196
[templates]
197-
prompt = { value = 'ln -sf "{{ filename }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
197+
prompt = { value = 'ln -sf "{{ file }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
198198
199199
# yes this is the pure plugin
200200
[plugins.pure]
@@ -221,7 +221,7 @@ use = ["{{ name }}.zsh"]
221221
apply = ["PATH", "source"]
222222
223223
[templates]
224-
prompt = { value = 'ln -sf "{{ filename }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
224+
prompt = { value = 'ln -sf "{{ file }}" "{{ root }}/functions/prompt_{{ name }}_setup"', each = true }
225225
226226
# yes this is the pure plugin
227227
[plugins.pure]

0 commit comments

Comments
 (0)