Skip to content

Commit

Permalink
Update JS options (+ max-passes)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianwong committed Oct 21, 2021
1 parent 4fe7bc1 commit 1e34286
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Prince.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Prince
// JavaScript options.
private $javascript;
private $scripts;
private $maxPasses;

// CSS options.
private $styleSheets;
Expand Down Expand Up @@ -173,6 +174,7 @@ public function __construct($exePath)
// JavaScript options.
$this->javascript = false;
$this->scripts = '';
$this->maxPasses = 0;

// CSS options.
$this->styleSheets = '';
Expand Down Expand Up @@ -951,6 +953,21 @@ public function clearScripts()
$this->scripts = '';
}

/**
* Specify the maximum number of consequent layout passes.
*
* @param int $maxPasses The maximum number of passes. Value must be greater
* than 0. Default value is unlimited passes.
* @return void
*/
public function setMaxPasses($maxPasses)
{
if ($maxPasses < 1) {
throw new Exception('invalid maxPasses value (must be > 0)');
}
$this->maxPasses = $maxPasses;
}

/* CSS OPTIONS ************************************************************/

/**
Expand Down Expand Up @@ -1471,6 +1488,9 @@ private function getCommandLine()
$cmdline .= '--javascript ';
}
$cmdline .= $this->scripts;
if ($this->maxPasses > 0) {
$cmdline .= '--max-passes="' . $this->maxPasses . '" ';
}

// CSS options.
$cmdline .= $this->styleSheets;
Expand Down

0 comments on commit 1e34286

Please sign in to comment.