Guest User

Untitled

a guest
May 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. var value = '{{tescior}}πŸ˜‚test😍😑testπŸ€—πŸ˜πŸ€£{{banana}} fd {{banana}} 😘 {{banana}}';
  2. var splited = value.split("{{");
  3.  
  4. var json =
  5. {
  6. document: {
  7. nodes: [
  8. {
  9. object: 'block',
  10. type: 'div',
  11. nodes: [
  12. {
  13. object: 'text',
  14. leaves: [
  15. {
  16. text: splited[0]
  17. }
  18. ]
  19. },
  20. ]
  21. }
  22. ]
  23. }
  24. }
  25.  
  26. splited.shift();
  27.  
  28. for(var split of splited) {
  29. var tmp = split.split("}}");
  30. json.document.nodes[0].nodes.push({
  31.  
  32. object: 'inline',
  33. data: {variable: tmp[0]},
  34. isVoid: true,
  35. type: 'variable',
  36. leaves: [
  37.  
  38. ]
  39. });
  40. json.document.nodes[0].nodes.push({
  41. object: 'text',
  42. leaves: [
  43. {
  44. text: tmp[1]
  45. }
  46.  
  47. ]
  48. });
  49. }
  50.  
  51. return json;
Add Comment
Please, Sign In to add comment