Extract compile function to another file

This commit is contained in:
Cadence Ember 2020-07-20 13:52:56 +12:00
parent 496d53f47e
commit 1c382d6dc2
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412
2 changed files with 15 additions and 12 deletions

View File

@ -1,16 +1,5 @@
const compile = require("pug").compile
const data = {...require("./base")}
/**
* @param {string} text
*/
function pug(text) {
let lines = text.split("\n")
while (lines[0] === "") lines.shift()
const indentLevel = lines[0].match(/^\t*/)[0].length
lines = lines.map(l => l.replace(new RegExp(`^\\t{0,${indentLevel}}`), ""))
return compile(lines.join("\n"))
}
const {pug} = require("./utils/functions")
;(() => {
data.go_to_profile = "Go to profile"

View File

@ -0,0 +1,14 @@
const compile = require("pug").compile
/**
* @param {string} text
*/
function pug(text) {
let lines = text.split("\n")
while (lines[0] === "") lines.shift()
const indentLevel = lines[0].match(/^\t*/)[0].length
lines = lines.map(l => l.replace(new RegExp(`^\\t{0,${indentLevel}}`), ""))
return compile(lines.join("\n"))
}
module.exports.pug = pug