Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var value = '{{tescior}}πtestππ‘testπ€ππ€£{{banana}} fd {{banana}} π {{banana}}';
- var splited = value.split("{{");
- var json =
- {
- document: {
- nodes: [
- {
- object: 'block',
- type: 'div',
- nodes: [
- {
- object: 'text',
- leaves: [
- {
- text: splited[0]
- }
- ]
- },
- ]
- }
- ]
- }
- }
- splited.shift();
- for(var split of splited) {
- var tmp = split.split("}}");
- json.document.nodes[0].nodes.push({
- object: 'inline',
- data: {variable: tmp[0]},
- isVoid: true,
- type: 'variable',
- leaves: [
- ]
- });
- json.document.nodes[0].nodes.push({
- object: 'text',
- leaves: [
- {
- text: tmp[1]
- }
- ]
- });
- }
- return json;
Add Comment
Please, Sign In to add comment