Processors to esm
This commit is contained in:
parent
e0873b359c
commit
cdf251f9cc
|
@ -1,6 +1,6 @@
|
|||
const { FIND_HBS_REGEX } = require("../utilities")
|
||||
const preprocessor = require("./preprocessor")
|
||||
const postprocessor = require("./postprocessor")
|
||||
import { FIND_HBS_REGEX } from "../utilities"
|
||||
import * as preprocessor from "./preprocessor"
|
||||
import * as postprocessor from "./postprocessor"
|
||||
|
||||
function process(output, processors, opts) {
|
||||
for (let processor of processors) {
|
||||
|
@ -21,7 +21,7 @@ function process(output, processors, opts) {
|
|||
return output
|
||||
}
|
||||
|
||||
module.exports.preprocess = (string, opts) => {
|
||||
export function preprocess(string, opts) {
|
||||
let processors = preprocessor.processors
|
||||
if (opts.noFinalise) {
|
||||
processors = processors.filter(
|
||||
|
@ -30,7 +30,7 @@ module.exports.preprocess = (string, opts) => {
|
|||
}
|
||||
return process(string, processors, opts)
|
||||
}
|
||||
module.exports.postprocess = string => {
|
||||
export function postprocess(string) {
|
||||
let processors = postprocessor.processors
|
||||
return process(string, processors)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { LITERAL_MARKER } = require("../helpers/constants")
|
||||
import { LITERAL_MARKER } from "../helpers/constants"
|
||||
|
||||
const PostProcessorNames = {
|
||||
export const PostProcessorNames = {
|
||||
CONVERT_LITERALS: "convert-literals",
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,7 @@ class Postprocessor {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports.PostProcessorNames = PostProcessorNames
|
||||
|
||||
module.exports.processors = [
|
||||
export const processors = [
|
||||
new Postprocessor(PostProcessorNames.CONVERT_LITERALS, statement => {
|
||||
if (typeof statement !== "string" || !statement.includes(LITERAL_MARKER)) {
|
||||
return statement
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const { HelperNames } = require("../helpers")
|
||||
const { swapStrings, isAlphaNumeric } = require("../utilities")
|
||||
import { HelperNames } from "../helpers"
|
||||
import { swapStrings, isAlphaNumeric } from "../utilities"
|
||||
|
||||
const FUNCTION_CASES = ["#", "else", "/"]
|
||||
|
||||
const PreprocessorNames = {
|
||||
export const PreprocessorNames = {
|
||||
SWAP_TO_DOT: "swap-to-dot-notation",
|
||||
FIX_FUNCTIONS: "fix-functions",
|
||||
FINALISE: "finalise",
|
||||
|
@ -23,7 +23,7 @@ class Preprocessor {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports.processors = [
|
||||
export const processors = [
|
||||
new Preprocessor(PreprocessorNames.SWAP_TO_DOT, statement => {
|
||||
let startBraceIdx = statement.indexOf("[")
|
||||
let lastIdx = 0
|
||||
|
@ -74,5 +74,3 @@ module.exports.processors = [
|
|||
return `{{ all ${insideStatement} }}`
|
||||
}),
|
||||
]
|
||||
|
||||
module.exports.PreprocessorNames = PreprocessorNames
|
||||
|
|
Loading…
Reference in New Issue