Skip to content

Commit

Permalink
Fix rendering of CLI help-message
Browse files Browse the repository at this point in the history
Fixes #124
  • Loading branch information
jaylinski committed Sep 6, 2023
1 parent d79e6af commit 13a2e2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/.vuepress/plugins/update-handlebars-cli-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function updateHandlebarsCliHelp() {
return {
name: "update the 'handlebars --help' output.",
extendMarkdown(md) {
md.block.ruler.before("fence", "handlebars_help_output", function(state, startLine, endLine, silent) {
md.block.ruler.before("fence", "handlebars_help_output", function (state, startLine, endLine, silent) {
const pos = state.bMarks[startLine] + state.tShift[startLine];
const max = state.eMarks[startLine];
if (state.src.slice(pos, max) !== "!HANDLEBARS_HELP!") {
Expand All @@ -29,17 +29,17 @@ export function updateHandlebarsCliHelp() {
token.map = [startLine, startLine + 1];
return true;
});
}
},
};
}

function getHandlebarsHelpFromCli() {
const handlebarsCli = require.resolve("handlebars/bin/handlebars");
const nodeExecutable = process.argv[0];
const { stderr } = cp.spawnSync(nodeExecutable, [handlebarsCli, "--help"], {
const { stdout } = cp.spawnSync(nodeExecutable, [handlebarsCli, "--help"], {
argv0: "handlebars",
stdio: ["pipe", "pipe", "pipe"],
encoding: "utf-8"
encoding: "utf-8",
});
return stderr.replace(/^Usage: \S+ \S+/m, "handlebars");
return stdout;
}
4 changes: 2 additions & 2 deletions src/installation/precompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ time, the `--knownOnly` option provides the smallest generated code that also pr
If using the precompiler's normal mode, the resulting templates will be stored to the Handlebars.templates object using
the relative template name sans the extension. These templates may be executed in the same manner as templates. If using
the simple mode the precompiler will generate a single javascript method. To execute this method it must be passed to
the Handlebars.template method and the resulting object may be used as normal.
the `Handlebars.template()` method and the resulting object may be used as normal.
## Precompiling Templates Inside NodeJS
Expand All @@ -75,7 +75,7 @@ Finally, you can reference these templates dynamically in your Javascript.
```js
var result = Handlebars.partials["test1"]({ name: "yourname" });
//do whatever you want with the result
// do whatever you want with the result
```
## Integrations
Expand Down
2 changes: 1 addition & 1 deletion src/zh/installation/precompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Handlebars 编译器将优化对这些 helper 的访问以提高性能。当所
如果使用预编译器的 normal 模式,则预编译结果将存储到 Handlebars.templates 对象下对应的模板名称(不带扩展名)的对象中。这
些预编译模板可以以和普通模板相同的方式执行。如果使用 simple 模式,预编译器将生成一个 JavaScript 方法。要执行此方法,必须
将其传递给 Handlebars.template 方法,生成的对象也可以以相同的方式使用。
将其传递给 `Handlebars.template()` 方法,生成的对象也可以以相同的方式使用。
## 在 NodeJS 中预编译模板
Expand Down

0 comments on commit 13a2e2d

Please sign in to comment.