File tree Expand file tree Collapse file tree 2 files changed +19
-14
lines changed
Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- function createVariables ( defaultData ) {
3+ function createInstance ( defaultData ) {
44
55 const DATA = {
66 _ : defaultData
@@ -37,22 +37,27 @@ function createVariables(defaultData) {
3737 } ,
3838 process : async str => {
3939
40- const reg = / { { \ * (?: \[ ( [ ^ { } ] + ) \] \ * ) ? ( [ ^ { } ] + ) \ * } } / g;
40+ const reg = / ( [ \\ ] ? ) { { \ * (?: \[ ( [ ^ { } ] + ) \] \ * ) ? ( [ ^ { } ] + ) \ * } } / g;
4141
4242 const ret = [ ] ;
4343 let match ;
4444 let i = 0 ;
4545 while ( ( match = reg . exec ( str ) ) !== null ) {
4646
47- const url = match [ 1 ] ;
48- const path = match [ 2 ] ;
47+ const opr = match [ 1 ] ;
4948
5049 ret . push ( str . slice ( i , match . index ) ) ;
5150
52- try {
53- ret . push ( await getValue ( url , path ) ) ;
54- } catch ( error ) {
55- ret . push ( "[ERROR]" ) ;
51+ if ( opr !== '\\' ) {
52+ const url = match [ 2 ] ;
53+ const path = match [ 3 ] ;
54+ try {
55+ ret . push ( await getValue ( url , path ) ) ;
56+ } catch ( error ) {
57+ ret . push ( "[ERROR]" ) ;
58+ }
59+ } else {
60+ ret . push ( ( match [ 0 ] + "" ) . slice ( 1 ) ) ;
5661 }
5762
5863 i = reg . lastIndex ;
@@ -64,5 +69,5 @@ function createVariables(defaultData) {
6469 }
6570}
6671
67- module . exports = createVariables ;
72+ module . exports = createInstance ;
6873
Original file line number Diff line number Diff line change 33const el = require ( './Elements.js' ) ;
44const textFormatting = require ( './TextFormatting.js' ) ;
55
6- const createVariables = require ( './Variables .js' ) ;
6+ const createInstance = require ( './Hyperdata .js' ) ;
77
8- let variables ;
8+ let hyperdata ;
99
1010function render ( data ) {
1111
12- variables = createVariables ( data ) ;
12+ hyperdata = createInstance ( data ) ;
1313
1414 el . append ( document . head , [
1515 el . create ( 'meta' , { charset : "utf-8" } ) ,
@@ -85,8 +85,8 @@ function setValue(el, str) {
8585 if ( ! str . includes ( '{{' ) ) {
8686 el . innerHTML = textFormatting ( str )
8787 } else {
88- el . innerHTML = textFormatting ( variables . replace ( str , "..." ) )
89- variables . process ( str )
88+ el . innerHTML = textFormatting ( hyperdata . replace ( str , "..." ) )
89+ hyperdata . process ( str )
9090 . then ( s => el . innerHTML = textFormatting ( s ) )
9191 . catch ( error => {
9292 console . error ( error ) ;
You can’t perform that action at this time.
0 commit comments