mirror of https://github.com/Budibase/budibase.git
11 changed files with 114 additions and 60 deletions
@ -1,24 +1,28 @@ |
|||
import commonjs from "rollup-plugin-commonjs" |
|||
import nodeResolve from "rollup-plugin-node-resolve" |
|||
import globals from "rollup-plugin-node-globals" |
|||
import resolve from "rollup-plugin-node-resolve" |
|||
import builtins from "rollup-plugin-node-builtins" |
|||
import globals from "rollup-plugin-node-globals" |
|||
import json from "@rollup/plugin-json" |
|||
|
|||
export default { |
|||
input: "src/index.js", |
|||
output: { |
|||
file: "dist/bundle.js", |
|||
format: "umd", |
|||
name: "string-templates", |
|||
exports: "named", |
|||
globals: { |
|||
fs: "fs", |
|||
output: [ |
|||
{ |
|||
sourcemap: true, |
|||
format: "umd", |
|||
file: "./dist/bundle.js", |
|||
name: "string-templates", |
|||
exports: "named", |
|||
}, |
|||
}, |
|||
external: ["fs"], |
|||
], |
|||
plugins: [ |
|||
nodeResolve({ preferBuiltins: false }), |
|||
resolve({ |
|||
preferBuiltins: true, |
|||
browser: true, |
|||
}), |
|||
commonjs(), |
|||
globals(), |
|||
builtins(), |
|||
json(), |
|||
], |
|||
} |
|||
|
|||
@ -0,0 +1,26 @@ |
|||
const { FIND_HBS_REGEX } = require("../utilities") |
|||
const preprocessor = require("./preprocessor") |
|||
const postprocessor = require("./postprocessor") |
|||
|
|||
function process(string, processors) { |
|||
for (let processor of processors) { |
|||
// re-run search each time incase previous processor updated/removed a match
|
|||
let regex = new RegExp(FIND_HBS_REGEX) |
|||
let matches = string.match(regex) |
|||
if (matches == null) { |
|||
continue |
|||
} |
|||
for (let match of matches) { |
|||
string = processor.process(string, match) |
|||
} |
|||
} |
|||
return string |
|||
} |
|||
|
|||
module.exports.preprocess = string => { |
|||
return process(string, preprocessor.processors) |
|||
} |
|||
|
|||
module.exports.postprocess = string => { |
|||
return process(string, postprocessor.processors) |
|||
} |
|||
@ -1,6 +1,9 @@ |
|||
/* eslint-disable no-unused-vars */ |
|||
class Postprocessor { |
|||
constructor(name, fn) { |
|||
this.name = name |
|||
this.fn = fn |
|||
} |
|||
} |
|||
|
|||
module.exports.processors = [] |
|||
Loading…
Reference in new issue