-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
29 lines (28 loc) · 1.06 KB
/
index.ts
File metadata and controls
29 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {
Pack, Block, Literal, Type, Dict
} from "dalkak";
export default new Pack({
name: "templater",
blocks: {
init: new Block({
name: "init",
template: "Templater 사용하기",
func: (param, project, platform: any) => {
var templater = valueField => (object, script) => {
var value = script.getField(valueField, script);
if(/{.*?}/g.exec(value) && /{.*?}/g.exec(value)[0] == value){
return project.variables.value[value.substring(1, value.length-1)].value
}else{
return value
.replace(
/{.*?}/g,
val => project.variables.value[val.substring(1, val.length-1)].value
);
}
}
platform.Entry.block.text.func = templater("NAME");
platform.Entry.block.number.func = templater("NUM");
}
})
}
});