pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
387 stars 42 forks source link

Fix space after tag interpolation #111

Closed rmrevin closed 7 years ago

rmrevin commented 7 years ago

This fix errors in tag interpolation. Current behavior:

p This is #[a(href="http://someurl.com") example] string.

Result:

<p>This is <a href="http://someurl.com">example</a>string.</p>

Space after anchor is lost. Need:

<p>This is <a href="http://someurl.com">example</a> string.</p>

I wanted to write a test for this case, but do not pass the tests. it was not possible to make a fix quickly.

rmrevin commented 7 years ago

The tests do not work if enabled xdebug.

codecov-io commented 7 years ago

Codecov Report

Merging #111 into master will not impact coverage.

@@          Coverage Diff          @@
##           master   #111   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          59     59           
  Lines        2343   2350    +7     
=====================================
+ Hits         2343   2350    +7
Impacted Files Coverage Δ
src/Jade/Compiler/TagVisitor.php 100% <100%> (ø) :white_check_mark:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f3ad360...f263f08. Read the comment docs.

rmrevin commented 7 years ago

Added test

kylekatarnls commented 7 years ago

Thanks a lot! But I'm sorry, there is a regression for the following code:

$html = $pug->render("p this is#[a(href='#') test]string");
$this->assertSame('<p>this is<a href="#">test</a>string</p>', $html);

Please let me know if you can provide a solution to also handle the case above. Else I will try to continue your branch.

kylekatarnls commented 7 years ago

Any way found to get this work without the regression above? If not, I will start working on it.

rmrevin commented 7 years ago

@kylekatarnls In the near future, I just can not deal with this issue. If you have a solution, I would be grateful for solving. Because Now library incorrectly renders templates.

kylekatarnls commented 7 years ago

Hi, I merged your commits and finally turn the main handle of white spaces into a parser evolution. Not yet perfect but it should have the expected result with no regression anywhere else. A really proper way to handle it will come with the next version.

rmrevin commented 7 years ago

@kylekatarnls Thank you very much for your work!