Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
proper comments indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed Aug 7, 2010
1 parent 275d821 commit 0ce32d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Everzet/Jade/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ protected function parseExpr()
case 'comment':
$tok = $this->advance();
$val = preg_replace(array("/^ */", "/ *$/"), '', $tok->val);
$indents = $this->getIndentation();
if (preg_match("/^\[if[^\]]+\]$/", $val)) {
$beg = sprintf('<!--%s>', $val);
$end = '<![endif]-->';
Expand All @@ -492,13 +493,12 @@ protected function parseExpr()
$end = "-->";
}
if ('indent' === $this->peek()->type) {
$indents = $this->getIndentation();
$buf = $beg . "\n";
if ('' !== $val) {
$buf .= $indents . $val . "\n";
}
$buf .= $this->parseBlock();
$buf .= $end;
$buf .= $indents . $end;
} else {
$buf = sprintf("<!-- %s -->", $val);
}
Expand Down
42 changes: 42 additions & 0 deletions tests/Everzet/Jade/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,48 @@ public function testHTMLConditionalComments()
<h1>Get Firefox</h1>
</a>
<![endif]-->
HTML;
$this->assertEquals($html, $this->parse($jade));

$jade = <<<Jade
!!! 5
html
- use_helper('LESS')
head
- include_http_metas()
- include_metas()
- include_title()
- include_less_stylesheets()
- include_javascripts()
/[if lt IE 9]
script( src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" )
/[if IE]
script( src="http://html5shiv.googlecode.com/svn/trunk/html5.js" )
script( src="http://html5shiv.googlecode.com/svn/trunk/html6.js" )
script( src="http://html5shiv.googlecode.com/svn/trunk/html7.js" )
Jade;
$html = <<<HTML
<!DOCTYPE html>
<html>
<?php use_helper('LESS') ?>
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<?php include_less_stylesheets() ?>
<?php include_javascripts() ?>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://html5shiv.googlecode.com/svn/trunk/html6.js"></script>
<script src="http://html5shiv.googlecode.com/svn/trunk/html7.js"></script>
<![endif]-->
</head>
</html>
HTML;
$this->assertEquals($html, $this->parse($jade));
}
Expand Down

0 comments on commit 0ce32d1

Please sign in to comment.