File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SyntaxPhoenix \EJSParserBundle \Exception ;
4+
5+ use Exception ;
6+
7+ class NoBlockException extends Exception
8+ {
9+ }
Original file line number Diff line number Diff line change 66use Exception ;
77use DOMDocument ;
88use Masterminds \HTML5 ;
9+ use SyntaxPhoenix \EJSParserBundle \Exception \NoBlockException ;
910use SyntaxPhoenix \EJSParserBundle \Parser \Extension \RawParser ;
1011use SyntaxPhoenix \EJSParserBundle \Parser \Extension \CodeParser ;
1112use SyntaxPhoenix \EJSParserBundle \Parser \Extension \LinkParser ;
@@ -69,9 +70,13 @@ public function setData(object $data): void
6970
7071 public function toHtml (): string
7172 {
72- $ this ->render ();
73-
74- return $ this ->dom ->saveHTML ();
73+ try {
74+ $ this ->render ();
75+
76+ return $ this ->dom ->saveHTML ();
77+ } catch (NoBlockException $ exception ) {
78+ return '' ;
79+ }
7580 }
7681
7782 private function hasBlocks ()
@@ -85,7 +90,7 @@ private function hasBlocks()
8590 private function render (): void
8691 {
8792 if (!$ this ->hasBlocks ()) {
88- throw new Exception ('No Blocks to parse ! ' );
93+ throw new NoBlockException ('No Blocks to parse ! ' );
8994 }
9095 foreach ($ this ->data ->blocks as $ block ) {
9196 if (array_key_exists ($ block ->type , $ this ->parser )) {
You can’t perform that action at this time.
0 commit comments