This commit is contained in:
Adria Navarro 2024-01-31 10:00:41 +01:00
parent 70d49bbd6b
commit e5d5dea5e6
5 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
const { getHelperList } = require("../helpers") const { getJsHelperList } = require("../helpers")
function getLayers(fullBlock) { function getLayers(fullBlock) {
let layers = [] let layers = []
@ -109,7 +109,7 @@ module.exports.convertHBSBlock = (block, blockNumber) => {
const layers = getLayers(block) const layers = getLayers(block)
let value = null let value = null
const list = getHelperList() const list = getJsHelperList()
for (let layer of layers) { for (let layer of layers) {
const parts = splitBySpace(layer) const parts = splitBySpace(layer)
if (value || parts.length > 1 || list[parts[0]]) { if (value || parts.length > 1 || list[parts[0]]) {

View File

@ -7,7 +7,7 @@ const {
HelperFunctionBuiltin, HelperFunctionBuiltin,
LITERAL_MARKER, LITERAL_MARKER,
} = require("./constants") } = require("./constants")
const { getHelperList } = require("./list") const { getJsHelperList } = require("./list")
const HTML_SWAPS = { const HTML_SWAPS = {
"<": "&lt;", "<": "&lt;",
@ -97,4 +97,4 @@ module.exports.unregisterAll = handlebars => {
externalHandlebars.unregisterAll(handlebars) externalHandlebars.unregisterAll(handlebars)
} }
module.exports.getHelperList = getHelperList module.exports.getJsHelperList = getJsHelperList

View File

@ -1,7 +1,7 @@
const { atob } = require("../utilities") const { atob } = require("../utilities")
const cloneDeep = require("lodash.clonedeep") const cloneDeep = require("lodash.clonedeep")
const { LITERAL_MARKER } = require("../helpers/constants") const { LITERAL_MARKER } = require("../helpers/constants")
const { getHelperList } = require("./list") const { getJsHelperList } = require("./list")
// The method of executing JS scripts depends on the bundle being built. // The method of executing JS scripts depends on the bundle being built.
// This setter is used in the entrypoint (either index.cjs or index.mjs). // This setter is used in the entrypoint (either index.cjs or index.mjs).
@ -49,7 +49,7 @@ module.exports.processJS = (handlebars, context) => {
// app context. // app context.
const sandboxContext = { const sandboxContext = {
$: path => getContextValue(path, cloneDeep(context)), $: path => getContextValue(path, cloneDeep(context)),
helpers: getHelperList(), helpers: getJsHelperList(),
} }
// Create a sandbox with our context and run the JS // Create a sandbox with our context and run the JS

View File

@ -5,7 +5,7 @@ let helpers = undefined
const helpersToRemove = ["sortBy"] const helpersToRemove = ["sortBy"]
module.exports.getHelperList = () => { module.exports.getJsHelperList = () => {
if (helpers) { if (helpers) {
return helpers return helpers
} }

View File

@ -24,7 +24,7 @@ const {
} = require("../src/index.cjs") } = require("../src/index.cjs")
const tk = require("timekeeper") const tk = require("timekeeper")
const { getHelperList } = require("../src/helpers") const { getJsHelperList } = require("../src/helpers")
tk.freeze("2021-01-21T12:00:00") tk.freeze("2021-01-21T12:00:00")
@ -109,7 +109,7 @@ describe("manifest", () => {
}) })
describe("can be parsed and run as js", () => { describe("can be parsed and run as js", () => {
const jsHelpers = getHelperList() const jsHelpers = getJsHelperList()
const jsExamples = Object.keys(examples).reduce((acc, v) => { const jsExamples = Object.keys(examples).reduce((acc, v) => {
acc[v] = examples[v].filter(([key]) => jsHelpers[key]) acc[v] = examples[v].filter(([key]) => jsHelpers[key])
return acc return acc