Subject | Hash | Author | Date (UTC) |
---|---|---|---|
simplify | 0b5f3574f190923b6eae6331e1734fc4a68d6bb6 | mucbuc | 2020-01-29 07:01:59 |
batch process templates | b38ef44adbc8af929decbebe2e064bc27e0a3340 | mucbuc | 2020-01-29 06:50:03 |
use minimist | 1b30469823408bb66e30b45812ba96016c84079f | mucbuc | 2020-01-29 06:40:46 |
use description instead of objective" | b0f58d1ea170055e3db94722d4cafb5da71aaaab | mucbuc | 2020-01-28 06:20:41 |
consolidate | 7e829f7e8ed6a7e5f783c0b0819643575f12a466 | mucbuc | 2020-01-27 13:57:24 |
objective | ba898495090457a37d56b7d6398c2951a3e7b85b | mucbuc | 2020-01-27 13:47:44 |
usage example | 7b04228abbef46e4821429dcaaee7f279cc81024 | mucbuc | 2020-01-27 13:35:59 |
cleanup | 444da418ea31cbead2c41ce85d5acfb468faee79 | mucbuc | 2020-01-27 13:17:10 |
reading from prjetect dir | 9b8e0802d9549e52041ffadeb085dae7f2b186b1 | mucbuc | 2020-01-27 06:12:39 |
formt script | f991001a06fa70aed0c656635cf5d1c22b896652 | mucbuc | 2020-01-27 06:07:22 |
format | 820f8f81267baf5de99a0115ff6e79efcc361f7a | mucbuc | 2020-01-27 06:06:19 |
first pass | 0d21989109ebba5aa9ce330612da271998b7a441 | mucbuc | 2020-01-27 06:06:00 |
File | Lines added | Lines deleted |
---|---|---|
README.md | 2 | 12 |
index.js | 7 | 13 |
templates/basic.md | 1 | 1 |
File README.md changed (mode: 100644) (index b087f29..1d89268) | |||
1 | 1 | use cases: | use cases: |
2 | 2 | ||
3 | 1. define template which gets filled out by contnts of file | ||
3 | 1. define template which gets filled out by contents of file | ||
4 | 4 | 2. concatenate documents | 2. concatenate documents |
5 | 5 | 3. | 3. |
6 | 6 | ||
7 | # {{value:package.json,title}} | ||
8 | |||
9 | # Interface | ||
10 | {{file:src/interface.h}} | ||
11 | |||
12 | # Guidelines | ||
13 | 1. Only operate on entire files or json | ||
14 | - encourages "clean" files | ||
15 | - language agnostic | ||
16 | |||
17 | 7 | # Usage | # Usage |
18 | 8 | ``` | ``` |
19 | ./index template/basic ../circuit | ||
9 | ./index template/basic --target ../circuit | ||
20 | 10 | ``` | ``` |
File index.js changed (mode: 100755) (index 9d8e9af..4f5a657) | |||
... | ... | const fs = require("fs"), | |
5 | 5 | path = require("path"), | path = require("path"), |
6 | 6 | args = require("minimist")(process.argv.slice(2)); | args = require("minimist")(process.argv.slice(2)); |
7 | 7 | ||
8 | const projectPath = args.target ? args.target : process.cwd(); | ||
8 | const projectPath = args.target ? args.target : process.cwd(), | ||
9 | interface = readFile(path.join(projectPath, "src", "interface.h")); | ||
9 | 10 | ||
10 | for (templatePath of args._) { | ||
11 | const script = "result = `" + readFile(templatePath) + "`;", | ||
12 | interface = readFile(path.join(projectPath, "src", "interface.h")), | ||
13 | package = readJSON(path.join(projectPath, "package.json")); | ||
14 | |||
15 | let context = { | ||
16 | title: package.name, | ||
17 | interface, | ||
18 | description: package.description | ||
19 | }; | ||
11 | let context = readJSON(path.join(projectPath, "package.json")); | ||
12 | context = Object.assign(context, { interface }); | ||
13 | vm.createContext(context); | ||
20 | 14 | ||
21 | vm.createContext(context); | ||
15 | for (templatePath of args._) { | ||
16 | const script = "result = `" + readFile(templatePath) + "`;"; | ||
22 | 17 | vm.runInContext(script, context); | vm.runInContext(script, context); |
23 | |||
24 | 18 | console.log(context.result); | console.log(context.result); |
25 | 19 | } | } |
26 | 20 |
File templates/basic.md changed (mode: 100644) (index bdad95d..c347c45) | |||
1 | # ${title} | ||
1 | # ${name} | ||
2 | 2 | ${description} | ${description} |
3 | 3 | ||
4 | 4 | # Interface | # Interface |