From cdbb4d3064b0efddaca0abc02e0e55ec13ba9537 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 07:11:33 +0200 Subject: [PATCH 01/12] Organized all env in env.js file. It allows us to overwrite these values. --- env.js | 18 ++++++++++++++++++ helpers.js | 40 +++++++++++++++++++--------------------- package.json | 10 ++++------ server.js | 3 +-- 4 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 env.js diff --git a/env.js b/env.js new file mode 100644 index 0000000..86d9ace --- /dev/null +++ b/env.js @@ -0,0 +1,18 @@ +import path from 'path'; + +/** + * Since this file overwrites environment variables from `config` lib. + * It's important to "import" this file before all scripts in entry point file, especially before `config`. + */ + +process.env.NODE_CONFIG_DIR = path.join(process.env.PROJECT_PATH ?? '', process.env.BLOCK_NAME ?? '', 'config'); + +/** + * Export constant variables + */ + +export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; +export const IS_DEV = process.env.NODE_ENV === 'development'; +export const BLOCK_NAME = process.env.BLOCK_NAME; +export const MODULE_PATH = process.env.MODULE_PATH ?? 'node_modules/block-dev-tool'; +export const PROJECT_PATH = process.env.PROJECT_PATH ? path.join(process.env.PROJECT_PATH, BLOCK_NAME) : ''; diff --git a/helpers.js b/helpers.js index 6c7016e..00146ac 100644 --- a/helpers.js +++ b/helpers.js @@ -1,4 +1,5 @@ import path from 'path'; +import {BLOCK_NAME, IS_DEV, MODULE_PATH, PROJECT_PATH} from "./env.js"; import config from 'config'; import {fileURLToPath} from 'url'; import memFs from 'mem-fs'; @@ -13,14 +14,11 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export function getConfigs() { - const isDev = process.env.NODE_ENV === 'development'; // Check README file in case you get "missing files" error. - const developmentBlockName = process.env.BLOCK_NAME; - return { - isDev, - developmentBlockName, - modulesPath: process.env.MODULE_PATH ?? (isDev ? '' : 'node_modules/block-dev-tool'), - projectPath: process.env.PROJECT_PATH ?? (isDev ? path.join('blocks', developmentBlockName) : ''), + isDev: IS_DEV, + developmentBlockName: BLOCK_NAME, + modulesPath: MODULE_PATH, + projectPath: PROJECT_PATH, }; } @@ -157,19 +155,19 @@ export async function zipProject(srcDir, outputFileName = 'dist.zip') { } export async function buildExportFiles(blockName, platform) { - if (platform.name.startsWith('wordpress')) { - if (platform.name === 'wordpress-acf-block') { - await buildWordPress(blockName, {block: true}); - } else if (platform.name === 'wordpress-elementor') { - await buildWordPress(blockName, {elementor: true}); - } else if (platform.name === 'wordpress-component-manager') { - await buildWordPress(blockName, {componentManager: true}); - } else { - await buildWordPress(blockName); - } - } else if (platform.name === 'hubspot-email') { - await buildHubspotEmail(blockName) - } else if (platform.name === 'hubspot') { - await buildHubspotPage(blockName) + if (platform.name.startsWith('wordpress')) { + if (platform.name === 'wordpress-acf-block') { + await buildWordPress(blockName, {block: true}); + } else if (platform.name === 'wordpress-elementor') { + await buildWordPress(blockName, {elementor: true}); + } else if (platform.name === 'wordpress-component-manager') { + await buildWordPress(blockName, {componentManager: true}); + } else { + await buildWordPress(blockName); } + } else if (platform.name === 'hubspot-email') { + await buildHubspotEmail(blockName) + } else if (platform.name === 'hubspot') { + await buildHubspotPage(blockName) + } } diff --git a/package.json b/package.json index b557ff9..e23f2b4 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,11 @@ "url": "https://axe-web.com/" }, "scripts": { - "start": "component-dev", "info": "node debug.js", - "dev": "NODE_ENV=development NODE_CONFIG_DIR=blocks/header/config BLOCK_NAME=header node server.js", - "build": "rollup --config rollup.config.js", - "build-platform": "NODE_ENV=development NODE_CONFIG_DIR=blocks/header/config BLOCK_NAME=header node ./build.js", - "build-platform-cli": "component-build", - "dev-js": "NODE_ENV=development rollup --config rollup.config.js --watch" + "dev": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node server.js", + "build-platform": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node ./build.js", + "dev-dev-tool": "NODE_ENV=development rollup --config rollup.config.js --watch", + "build-dev-tool": "rollup --config rollup.config.js" }, "license": "ISC", "type": "module", diff --git a/server.js b/server.js index bd069af..92481b7 100755 --- a/server.js +++ b/server.js @@ -1,5 +1,6 @@ #!/usr/bin/env node +import {PRODUCTION_REGISTRY_URL} from "./env.js"; import path from 'path'; import fetch from "node-fetch"; import express from 'express'; @@ -25,8 +26,6 @@ import PluginError from 'plugin-error'; * Constants */ -const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; - const {isDev, modulesPath, projectPath, developmentBlockName} = getConfigs(); const blocksRegistry = isDev ? 'http://localhost:3020' : PRODUCTION_REGISTRY_URL; From f9c0852ede968a1ccaf3b3cd4dd2d5666d8ddee3 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 07:13:01 +0200 Subject: [PATCH 02/12] - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e23f2b4..d7d2c80 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "component-build": "./build.js" }, "files": [ + "env.js", "helpers.js", "debug.js", "layouts/**/*.hbs", From de0b6740d1918f616763cab56142d507ae491e95 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 07:41:39 +0200 Subject: [PATCH 03/12] - Simplify the process of env variables setup. Provide default values. - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- env.js | 48 ++++++++++++++++++++++++++++++++++++++++++------ package.json | 9 +++++---- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/env.js b/env.js index 86d9ace..97c464e 100644 --- a/env.js +++ b/env.js @@ -1,18 +1,54 @@ import path from 'path'; /** - * Since this file overwrites environment variables from `config` lib. - * It's important to "import" this file before all scripts in entry point file, especially before `config`. + * Since this file overwrites environment variables for `config` lib, + * it's important to "import" this file before all scripts in entry point file, + * especially before `config` module import. */ -process.env.NODE_CONFIG_DIR = path.join(process.env.PROJECT_PATH ?? '', process.env.BLOCK_NAME ?? '', 'config'); /** * Export constant variables */ - export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; export const IS_DEV = process.env.NODE_ENV === 'development'; export const BLOCK_NAME = process.env.BLOCK_NAME; -export const MODULE_PATH = process.env.MODULE_PATH ?? 'node_modules/block-dev-tool'; -export const PROJECT_PATH = process.env.PROJECT_PATH ? path.join(process.env.PROJECT_PATH, BLOCK_NAME) : ''; +export const MODULE_PATH = getModulePath(); +export const PROJECT_PATH = getProjectPath(); + + +/** + * Overwrite env variables. + */ + +process.env.NODE_CONFIG_DIR = path.join(PROJECT_PATH, 'config'); + + +/** + * Private functions. + * Don't export these, export constants. + */ + +function getModulePath() { + let modulePath = 'node_modules/block-dev-tool'; + + if (typeof process.env.MODULE_PATH !== 'undefined') { + modulePath = process.env.MODULE_PATH; + } else if (BLOCK_NAME) { + modulePath = 'node_modules/@axe-web/block-dev-tool'; + } + + return modulePath; +} + +function getProjectPath() { + let projectPath = ''; + + if (typeof process.env.PROJECT_PATH !== 'undefined') { + projectPath = path.join(process.env.PROJECT_PATH, BLOCK_NAME) + } else if (BLOCK_NAME) { + projectPath = path.join('blocks', BLOCK_NAME) + } + + return projectPath; +} diff --git a/package.json b/package.json index d7d2c80..6aad4ff 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "url": "https://axe-web.com/" }, "scripts": { - "info": "node debug.js", - "dev": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node server.js", - "build-platform": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= PROJECT_PATH=blocks node ./build.js", + "info": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= node debug.js", + "dev": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= node server.js", + "build-platform": "NODE_ENV=development BLOCK_NAME=header MODULE_PATH= node ./build.js", "dev-dev-tool": "NODE_ENV=development rollup --config rollup.config.js --watch", "build-dev-tool": "rollup --config rollup.config.js" }, @@ -58,7 +58,8 @@ }, "bin": { "component-dev": "./server.js", - "component-build": "./build.js" + "component-build": "./build.js", + "component-info": "./debug.js" }, "files": [ "env.js", From 1a98a60facca19822f8b4919bd11cc2b95762c5d Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 12:26:54 +0200 Subject: [PATCH 04/12] - Make sure we can overwrite MODULE_PATH and PROJECT_PATH. - Simplify the process of env variables setup. Provide default values. - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- env.js | 12 +++++------- helpers.js | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/env.js b/env.js index 97c464e..d8816b1 100644 --- a/env.js +++ b/env.js @@ -14,14 +14,12 @@ export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; export const IS_DEV = process.env.NODE_ENV === 'development'; export const BLOCK_NAME = process.env.BLOCK_NAME; export const MODULE_PATH = getModulePath(); -export const PROJECT_PATH = getProjectPath(); - /** * Overwrite env variables. */ -process.env.NODE_CONFIG_DIR = path.join(PROJECT_PATH, 'config'); +process.env.NODE_CONFIG_DIR = path.join(getProjectPath(), 'config'); /** @@ -41,13 +39,13 @@ function getModulePath() { return modulePath; } -function getProjectPath() { +export function getProjectPath() { let projectPath = ''; if (typeof process.env.PROJECT_PATH !== 'undefined') { - projectPath = path.join(process.env.PROJECT_PATH, BLOCK_NAME) - } else if (BLOCK_NAME) { - projectPath = path.join('blocks', BLOCK_NAME) + projectPath = path.join(process.env.PROJECT_PATH ?? '', process.env.BLOCK_NAME ?? '') + } else if (process.env.BLOCK_NAME) { + projectPath = path.join('blocks', process.env.BLOCK_NAME ?? '') } return projectPath; diff --git a/helpers.js b/helpers.js index 00146ac..343c514 100644 --- a/helpers.js +++ b/helpers.js @@ -1,5 +1,5 @@ import path from 'path'; -import {BLOCK_NAME, IS_DEV, MODULE_PATH, PROJECT_PATH} from "./env.js"; +import {BLOCK_NAME, getProjectPath, IS_DEV, MODULE_PATH} from "./env.js"; import config from 'config'; import {fileURLToPath} from 'url'; import memFs from 'mem-fs'; @@ -18,7 +18,7 @@ export function getConfigs() { isDev: IS_DEV, developmentBlockName: BLOCK_NAME, modulesPath: MODULE_PATH, - projectPath: PROJECT_PATH, + projectPath: getProjectPath(), }; } From b43a4d6b4f6c6c6db7a7e74ea8d7b204d27440fa Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 12:31:39 +0200 Subject: [PATCH 05/12] - Make sure we can overwrite MODULE_PATH and PROJECT_PATH. - Simplify the process of env variables setup. Provide default values. - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- env.js | 5 ++--- helpers.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/env.js b/env.js index d8816b1..7055e47 100644 --- a/env.js +++ b/env.js @@ -13,7 +13,6 @@ import path from 'path'; export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; export const IS_DEV = process.env.NODE_ENV === 'development'; export const BLOCK_NAME = process.env.BLOCK_NAME; -export const MODULE_PATH = getModulePath(); /** * Overwrite env variables. @@ -27,12 +26,12 @@ process.env.NODE_CONFIG_DIR = path.join(getProjectPath(), 'config'); * Don't export these, export constants. */ -function getModulePath() { +export function getModulePath() { let modulePath = 'node_modules/block-dev-tool'; if (typeof process.env.MODULE_PATH !== 'undefined') { modulePath = process.env.MODULE_PATH; - } else if (BLOCK_NAME) { + } else if (process.env.BLOCK_NAME) { modulePath = 'node_modules/@axe-web/block-dev-tool'; } diff --git a/helpers.js b/helpers.js index 343c514..9f35b04 100644 --- a/helpers.js +++ b/helpers.js @@ -1,5 +1,5 @@ import path from 'path'; -import {BLOCK_NAME, getProjectPath, IS_DEV, MODULE_PATH} from "./env.js"; +import {BLOCK_NAME, getModulePath, getProjectPath, IS_DEV} from "./env.js"; import config from 'config'; import {fileURLToPath} from 'url'; import memFs from 'mem-fs'; @@ -17,7 +17,7 @@ export function getConfigs() { return { isDev: IS_DEV, developmentBlockName: BLOCK_NAME, - modulesPath: MODULE_PATH, + modulesPath: getModulePath(), projectPath: getProjectPath(), }; } From c1340f203570ea7f147a40695a30207f21511a55 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 12:46:03 +0200 Subject: [PATCH 06/12] - Added notes for future tests. - Make sure we can overwrite MODULE_PATH and PROJECT_PATH. - Simplify the process of env variables setup. Provide default values. - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- env.js | 5 ----- test.js | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 test.js diff --git a/env.js b/env.js index 7055e47..6921469 100644 --- a/env.js +++ b/env.js @@ -21,11 +21,6 @@ export const BLOCK_NAME = process.env.BLOCK_NAME; process.env.NODE_CONFIG_DIR = path.join(getProjectPath(), 'config'); -/** - * Private functions. - * Don't export these, export constants. - */ - export function getModulePath() { let modulePath = 'node_modules/block-dev-tool'; diff --git a/test.js b/test.js new file mode 100644 index 0000000..8a8afcc --- /dev/null +++ b/test.js @@ -0,0 +1,10 @@ +/** + * FUTURE TESTS. + * + * # ENV + * In `blocks-builder` service, we update MODULE_PATH and PROJECT_PATH environment variables before we run platform + * bundle build process. Actually before we call buildExportFiles(). + * + * We have to make sure that this logic is working properly and stable. + * + */ From dd860ec4734fbcfc1fd71938722b5e0af7a84eee Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 12:46:54 +0200 Subject: [PATCH 07/12] 1.0.26 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62995fc..1807f65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@axe-web/block-dev-tool", - "version": "1.0.25", + "version": "1.0.26", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@axe-web/block-dev-tool", - "version": "1.0.25", + "version": "1.0.26", "license": "ISC", "dependencies": { "@braintree/sanitize-url": "^6.0.0", diff --git a/package.json b/package.json index 6aad4ff..f7b8e40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@axe-web/block-dev-tool", - "version": "1.0.25", + "version": "1.0.26", "author": { "name": "AXE-WEB", "email": "office@axe-web.com", From bd5cafa549f4953fa4d4a1e590c088c27f7dd56b Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 9 Dec 2022 17:54:41 +0200 Subject: [PATCH 08/12] - Support Zip archive with provided PROJECT_PATH. - Added notes for future tests. - Make sure we can overwrite MODULE_PATH and PROJECT_PATH. - Simplify the process of env variables setup. Provide default values. - Include env.js in package.json Organized all env in env.js file. It allows us to overwrite these values. --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 92481b7..0a564e5 100755 --- a/server.js +++ b/server.js @@ -131,7 +131,7 @@ app.get('/publish', async (req, res) => { } if (responseData.uploadUrl) { - await zipProject(path.join(projectPath, 'src')); + await zipProject(path.join(projectPath, 'src'), path.join(projectPath, 'disp.zip')); const body = await fs.readFile(path.join(projectPath, 'dist.zip')); const response = await fetch(`${responseData.uploadUrl}`, { method: 'PUT', @@ -227,7 +227,7 @@ function startBrowserSync() { return cb(); }])); - bs.watch("src/**/*.hbs", function (event, file) { + bs.watch(path.join(projectPath, "src/**/*.hbs"), function (event, file) { browserSyncReload(bs, '', 'Template File Change: ' + file) }); From 3c163b8e76fc1bfabed97d9c8d5ba1793686d814 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Sun, 11 Dec 2022 15:08:01 +0200 Subject: [PATCH 09/12] Fix zip archive typo. --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 0a564e5..1fbf80f 100755 --- a/server.js +++ b/server.js @@ -131,7 +131,7 @@ app.get('/publish', async (req, res) => { } if (responseData.uploadUrl) { - await zipProject(path.join(projectPath, 'src'), path.join(projectPath, 'disp.zip')); + await zipProject(path.join(projectPath, 'src'), path.join(projectPath, 'dist.zip')); const body = await fs.readFile(path.join(projectPath, 'dist.zip')); const response = await fetch(`${responseData.uploadUrl}`, { method: 'PUT', From e9827fdd88a66637e78de28316bbf79d7edf862c Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Wed, 14 Dec 2022 12:01:52 +0200 Subject: [PATCH 10/12] Fix dist path of hubspot blocks. --- platforms/hubspot/hubspot-email-adapter.js | 4 ++-- platforms/hubspot/hubspot-page-adapter.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platforms/hubspot/hubspot-email-adapter.js b/platforms/hubspot/hubspot-email-adapter.js index ba1618d..14a0f32 100644 --- a/platforms/hubspot/hubspot-email-adapter.js +++ b/platforms/hubspot/hubspot-email-adapter.js @@ -18,8 +18,8 @@ export async function buildHubspotEmail(blockName) { }); } -export async function createDistFolder(blockName) { - const distPath = path.join('exports', 'hubspot', `${blockName}.module`); +export async function createDistFolder(blockName, projectPath = '') { + const distPath = path.join(projectPath, 'exports', 'hubspot', `${blockName}.module`); await mkdir(distPath, {recursive: true}) return distPath; diff --git a/platforms/hubspot/hubspot-page-adapter.js b/platforms/hubspot/hubspot-page-adapter.js index f5096c0..a9b1cf7 100644 --- a/platforms/hubspot/hubspot-page-adapter.js +++ b/platforms/hubspot/hubspot-page-adapter.js @@ -5,7 +5,7 @@ import {buildHubspotJSONFiles, createDistFolder, handlebarsToHubl,} from "./hubs export async function buildHubspotPage(blockName) { const {modulesPath, projectPath} = getConfigs(); - const distPath = await createDistFolder(blockName); + const distPath = await createDistFolder(blockName, projectPath); const srcPath = path.join(projectPath, 'src'); From f236674c1ec1ec05ace0f70b7f5fe11189ca171d Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Wed, 14 Dec 2022 12:51:43 +0200 Subject: [PATCH 11/12] Update logic of hubspot builder. --- platforms/hubspot/hubspot-email-adapter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platforms/hubspot/hubspot-email-adapter.js b/platforms/hubspot/hubspot-email-adapter.js index 14a0f32..786a19c 100644 --- a/platforms/hubspot/hubspot-email-adapter.js +++ b/platforms/hubspot/hubspot-email-adapter.js @@ -250,7 +250,8 @@ export async function buildHubspotJSONFiles(distPath, metaData) { export function handlebarsToHubl(handlebars) { handlebars = handlebars.replace(/{{#if /g, '{% if module.'); handlebars = handlebars.replace(/{{\/if}}/g, '{% endif %}'); - handlebars = handlebars.replace(/{{#each /g, '{% for module.'); + handlebars = handlebars.replace(/{{#each /g, '{% for item in module.'); + handlebars = handlebars.replace(/{{ else }}/g, '{% else %}'); handlebars = handlebars.replace(/{{\/each}}/g, '{% endfor %}'); handlebars = handlebars.replace(/{{base_url}}/g, ''); handlebars = handlebars.replace(/{esc_attr /g, '{'); @@ -262,6 +263,7 @@ export function handlebarsToHubl(handlebars) { handlebars = handlebars.replace(/}}}/g, '}}'); handlebars = handlebars.replace(/{{/g, '{{module.'); handlebars = handlebars.replace(/{{module. /g, '{{ module.'); + handlebars = handlebars.replace(/.url/g, '.src'); return handlebars; } From 269fbbc401440b20a5724356cf776d94be007914 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Wed, 14 Dec 2022 16:07:42 +0200 Subject: [PATCH 12/12] Update logic of hubspot builder. --- platforms/hubspot/hubspot-email-adapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platforms/hubspot/hubspot-email-adapter.js b/platforms/hubspot/hubspot-email-adapter.js index 786a19c..b965372 100644 --- a/platforms/hubspot/hubspot-email-adapter.js +++ b/platforms/hubspot/hubspot-email-adapter.js @@ -248,10 +248,11 @@ export async function buildHubspotJSONFiles(distPath, metaData) { export function handlebarsToHubl(handlebars) { + handlebars = handlebars.replace(/{{ else }}/g, '{% else %}'); + handlebars = handlebars.replace(/{{else}}/g, '{% else %}'); handlebars = handlebars.replace(/{{#if /g, '{% if module.'); handlebars = handlebars.replace(/{{\/if}}/g, '{% endif %}'); handlebars = handlebars.replace(/{{#each /g, '{% for item in module.'); - handlebars = handlebars.replace(/{{ else }}/g, '{% else %}'); handlebars = handlebars.replace(/{{\/each}}/g, '{% endfor %}'); handlebars = handlebars.replace(/{{base_url}}/g, ''); handlebars = handlebars.replace(/{esc_attr /g, '{');