@@ -39,10 +39,14 @@ function addAlias($alias, $original)
3939 /**
4040 * Process (merge) components
4141 * @param string $html
42+ * @param array $options
4243 * @return string
4344 */
44- public function process ($ html )
45+ public function process ($ html, $ options = [] )
4546 {
47+ if (isset ($ options ['_internal_process_components ' ]) && $ options ['_internal_process_components ' ] === false ) {
48+ return $ html ;
49+ }
4650 $ domDocument = new \IvoPetkov \HTML5DOMDocument ();
4751 $ domDocument ->loadHTML ($ html );
4852 $ componentElements = $ domDocument ->getElementsByTagName ('component ' );
@@ -60,10 +64,14 @@ public function process($html)
6064 }
6165 if (sizeof ($ sourceParts ) === 2 ) {
6266 $ 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+ }
6371 if ($ scheme === 'data ' ) {
64- $ componentHTML = $ this ->processData ($ sourceParts [1 ]);
72+ $ componentHTML = $ this ->processData ($ sourceParts [1 ], isset ( $ componentOptions ) ? $ componentOptions : $ options );
6573 } 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 );
6775 } else {
6876 throw new \Exception ('URI scheme not valid! ' . $ domDocument ->saveHTML ($ component ));
6977 }
@@ -101,28 +109,30 @@ public function process($html)
101109 /**
102110 *
103111 * @param string $data
112+ * @param array $options
104113 * @return string
105114 */
106- public function processData ($ data )
115+ public function processData ($ data, $ options = [] )
107116 {
108117 $ html = $ data ;
109118 if (substr ($ data , 0 , 7 ) === 'base64, ' ) {
110119 $ html = base64_decode (substr ($ data , 7 ));
111120 }
112- return $ this ->process ($ html );
121+ return $ this ->process ($ html, $ options );
113122 }
114123
115124 /**
116125 *
117126 * @param string $file
118127 * @param array $attributes
119128 * @param string $innerHTML
129+ * @param array $options
120130 * @return string
121131 */
122- public function processFile ($ file , $ attributes = [], $ innerHTML = '' )
132+ public function processFile ($ file , $ attributes = [], $ innerHTML = '' , $ options = [] )
123133 {
124134 $ component = $ this ->constructComponent ($ attributes , $ innerHTML );
125- return $ this ->process ($ this ->getComponentFileContent ($ file , $ component ));
135+ return $ this ->process ($ this ->getComponentFileContent ($ file , $ component ), $ options );
126136 }
127137
128138 /**
0 commit comments