mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 08:07:30 +00:00
Extract compile function to another file
This commit is contained in:
parent
496d53f47e
commit
1c382d6dc2
@ -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"
|
||||
|
14
src/lang/utils/functions.js
Normal file
14
src/lang/utils/functions.js
Normal 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
|
Loading…
Reference in New Issue
Block a user