md-template-vars 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# md-template-vars
|
|
2
|
+
|
|
3
|
+
A CLI tool to replace `{{variables}}` in Markdown templates with values from a YAML file.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g md-template-vars
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx md-template-vars ./templates ./output
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
md-template-vars <input> <output> [options]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Arguments
|
|
24
|
+
|
|
25
|
+
| Argument | Description |
|
|
26
|
+
| -------- | ----------------------------------------- |
|
|
27
|
+
| `input` | Input directory containing template files |
|
|
28
|
+
| `output` | Output directory for processed files |
|
|
29
|
+
|
|
30
|
+
### Options
|
|
31
|
+
|
|
32
|
+
| Option | Default | Description |
|
|
33
|
+
| ----------- | ---------------- | -------------------------------------- |
|
|
34
|
+
| `--vars` | `variables.yaml` | Path to the variables YAML file |
|
|
35
|
+
| `--include` | - | Glob pattern to include specific files |
|
|
36
|
+
| `--exclude` | - | Glob pattern to exclude specific files |
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Basic usage
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
md-template-vars ./templates ./output
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Custom variables file
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
md-template-vars ./templates ./output --vars production.yaml
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Filter files
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Include only files matching pattern
|
|
56
|
+
md-template-vars ./templates ./output --include "api-*.md"
|
|
57
|
+
|
|
58
|
+
# Exclude files matching pattern
|
|
59
|
+
md-template-vars ./templates ./output --exclude "draft-*.md"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Template Syntax
|
|
63
|
+
|
|
64
|
+
Use `{{variableName}}` syntax in your Markdown files:
|
|
65
|
+
|
|
66
|
+
**Template (templates/hello.md):**
|
|
67
|
+
```markdown
|
|
68
|
+
# Hello {{name}}
|
|
69
|
+
|
|
70
|
+
Welcome to {{project}}!
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Variables (variables.yaml):**
|
|
74
|
+
```yaml
|
|
75
|
+
name: World
|
|
76
|
+
project: My Project
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Output (output/hello.md):**
|
|
80
|
+
```markdown
|
|
81
|
+
# Hello World
|
|
82
|
+
|
|
83
|
+
Welcome to My Project!
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Error Handling
|
|
87
|
+
|
|
88
|
+
| Case | Behavior |
|
|
89
|
+
| --------------------------- | --------------------------------------------------- |
|
|
90
|
+
| Undefined variable | Warning is displayed, variable syntax is kept as-is |
|
|
91
|
+
| Same input/output directory | Error and exit |
|
|
92
|
+
| Variables file not found | Error and exit |
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "md-template-vars",
|
|
3
3
|
"author": "Shunta Toda",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "Replace {{variables}} in markdown templates with YAML values",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/application/use-cases/process-templates.js",
|