From 0810375d4585e07665a6d7be32f1c73a754e0c16 Mon Sep 17 00:00:00 2001 From: Jakob Linskeseder Date: Wed, 30 Aug 2023 23:16:41 +0200 Subject: [PATCH] Fix rendering of CLI help-message Fixes #124 --- src/.vuepress/plugins/update-handlebars-cli-help.js | 10 +++++----- src/installation/precompilation.md | 4 ++-- src/zh/installation/precompilation.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/.vuepress/plugins/update-handlebars-cli-help.js b/src/.vuepress/plugins/update-handlebars-cli-help.js index 1defd73c..9a8e03ce 100644 --- a/src/.vuepress/plugins/update-handlebars-cli-help.js +++ b/src/.vuepress/plugins/update-handlebars-cli-help.js @@ -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!") { @@ -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; } diff --git a/src/installation/precompilation.md b/src/installation/precompilation.md index 50005763..f94770b3 100644 --- a/src/installation/precompilation.md +++ b/src/installation/precompilation.md @@ -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 @@ -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 diff --git a/src/zh/installation/precompilation.md b/src/zh/installation/precompilation.md index 2da2cff1..c5437770 100644 --- a/src/zh/installation/precompilation.md +++ b/src/zh/installation/precompilation.md @@ -46,7 +46,7 @@ Handlebars 编译器将优化对这些 helper 的访问以提高性能。当所 如果使用预编译器的 normal 模式,则预编译结果将存储到 Handlebars.templates 对象下对应的模板名称(不带扩展名)的对象中。这 些预编译模板可以以和普通模板相同的方式执行。如果使用 simple 模式,预编译器将生成一个 JavaScript 方法。要执行此方法,必须 -将其传递给 Handlebars.template 方法,生成的对象也可以以相同的方式使用。 +将其传递给 `Handlebars.template()` 方法,生成的对象也可以以相同的方式使用。 ## 在 NodeJS 中预编译模板