コード例 #1
0
ファイル: IndenterTest.php プロジェクト: at15/dindent
 /**
  * @expectedException Gajus\Dindent\Exception\InvalidArgumentException
  * @expectedExceptionMessage Unrecognized element type.
  */
 public function testSetInvalidElementType()
 {
     $indenter = new \Gajus\Dindent\Indenter();
     $indenter->setElementType('foo', 'bar');
 }
コード例 #2
0
ファイル: dindent.php プロジェクト: at15/dindent
    ./dindent.php --input="./input.html" --indentation_character="\\t"
        Indent "input.html" file using tab to indent the markup.

    ./dindent.php --input="./input.html" --inline="div,p"
        Indent "input.html" file treating <div> and <p> elements as inline.

    ./dindent.php --input="./input.html" --block="span,em"
        Indent "input.html" file treating <span> and <em> elements as block.
';
    exit;
}
if (!isset($options['input'])) {
    error('Missing "input" parameter.');
} else {
    if (!file_exists($options['input'])) {
        error('"input" file does not exist.');
    }
}
$indenter = new \Gajus\Dindent\Indenter(isset($options['indentation_character']) ? array('indentation_character' => $options['indentation_character']) : array());
if (isset($options['inline'])) {
    foreach (explode(',', $options['inline']) as $element_name) {
        $indenter->setElementType($element_name, \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
    }
}
if (isset($options['block'])) {
    foreach (explode(',', $options['block']) as $element_name) {
        $indenter->setElementType($element_name, \Gajus\Dindent\Indenter::ELEMENT_TYPE_BLOCK);
    }
}
$output = $indenter->indent(file_get_contents($options['input']));
echo $output;