@@ -39,10 +39,14 @@ function addAlias($alias, $original)
39
39
/**
40
40
* Process (merge) components
41
41
* @param string $html
42
+ * @param array $options
42
43
* @return string
43
44
*/
44
- public function process ($ html )
45
+ public function process ($ html, $ options = [] )
45
46
{
47
+ if (isset ($ options ['_internal_process_components ' ]) && $ options ['_internal_process_components ' ] === false ) {
48
+ return $ html ;
49
+ }
46
50
$ domDocument = new \IvoPetkov \HTML5DOMDocument ();
47
51
$ domDocument ->loadHTML ($ html );
48
52
$ componentElements = $ domDocument ->getElementsByTagName ('component ' );
@@ -60,10 +64,14 @@ public function process($html)
60
64
}
61
65
if (sizeof ($ sourceParts ) === 2 ) {
62
66
$ scheme = $ sourceParts [0 ];
67
+ if (isset ($ options ['recursive ' ]) && $ options ['recursive ' ] === false && ($ scheme === 'data ' || $ scheme === 'file ' )) {
68
+ $ componentOptions = array_values ($ options );
69
+ $ componentOptions ['_internal_process_components ' ] = false ;
70
+ }
63
71
if ($ scheme === 'data ' ) {
64
- $ componentHTML = $ this ->processData ($ sourceParts [1 ]);
72
+ $ componentHTML = $ this ->processData ($ sourceParts [1 ], isset ( $ componentOptions ) ? $ componentOptions : $ options );
65
73
} elseif ($ scheme === 'file ' ) {
66
- $ componentHTML = $ this ->processFile (urldecode ($ sourceParts [1 ]), $ attributes , $ component ->innerHTML );
74
+ $ componentHTML = $ this ->processFile (urldecode ($ sourceParts [1 ]), $ attributes , $ component ->innerHTML , isset ( $ componentOptions ) ? $ componentOptions : $ options );
67
75
} else {
68
76
throw new \Exception ('URI scheme not valid! ' . $ domDocument ->saveHTML ($ component ));
69
77
}
@@ -101,28 +109,30 @@ public function process($html)
101
109
/**
102
110
*
103
111
* @param string $data
112
+ * @param array $options
104
113
* @return string
105
114
*/
106
- public function processData ($ data )
115
+ public function processData ($ data, $ options = [] )
107
116
{
108
117
$ html = $ data ;
109
118
if (substr ($ data , 0 , 7 ) === 'base64, ' ) {
110
119
$ html = base64_decode (substr ($ data , 7 ));
111
120
}
112
- return $ this ->process ($ html );
121
+ return $ this ->process ($ html, $ options );
113
122
}
114
123
115
124
/**
116
125
*
117
126
* @param string $file
118
127
* @param array $attributes
119
128
* @param string $innerHTML
129
+ * @param array $options
120
130
* @return string
121
131
*/
122
- public function processFile ($ file , $ attributes = [], $ innerHTML = '' )
132
+ public function processFile ($ file , $ attributes = [], $ innerHTML = '' , $ options = [] )
123
133
{
124
134
$ component = $ this ->constructComponent ($ attributes , $ innerHTML );
125
- return $ this ->process ($ this ->getComponentFileContent ($ file , $ component ));
135
+ return $ this ->process ($ this ->getComponentFileContent ($ file , $ component ), $ options );
126
136
}
127
137
128
138
/**
0 commit comments