Talesoft / tale-jade

A complete and fully-functional implementation of the Jade template language for PHP
http://jade.talesoft.codes
MIT License
88 stars 10 forks source link

Some html tags are processed incorrectly #33

Closed berkus closed 8 years ago

berkus commented 8 years ago
meta(name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0")
meta(http-equiv="X-UA-Compatible" content="chrome=1")

link(rel="shortcut icon" href="/favicon.ico")
link(rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600")

link(rel="stylesheet" href="/style.css")

Section like this is parsed correctly by Node jade, but in TaleJade it turns into a mess that fails to even compile. Is it me doing something wrong or Node's jade is not fully compatible?

berkus commented 8 years ago
    <meta<?php $__value = "viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"; if (!\Tale\Jade\Compiler::isNullOrFalse($__value)) echo ' name='.\Tale\Jade\Compiler::buildValue($__value, '"', true); unset($__value);?>></meta>
    <meta<?php $__value = "X-UA-Compatible" content="chrome=1"; if (!\Tale\Jade\Compiler::isNullOrFalse($__value)) echo ' http-equiv='.\Tale\Jade\Compiler::buildValue($__value, '"', true); unset($__value);?>></meta>
    <link<?php $__value = "shortcut icon" href="/favicon.ico"; if (!\Tale\Jade\Compiler::isNullOrFalse($__value)) echo ' rel='.\Tale\Jade\Compiler::buildValue($__value, '"', true); unset($__value);?>>
    <link<?php $__value = "stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600"; if (!\Tale\Jade\Compiler::isNullOrFalse($__value)) echo ' rel='.\Tale\Jade\Compiler::buildValue($__value, '"', true); unset($__value);?>>
    <link<?php $__value = "stylesheet" href="/style.css"; if (!\Tale\Jade\Compiler::isNullOrFalse($__value)) echo ' rel='.\Tale\Jade\Compiler::buildValue($__value, '"', true); unset($__value);?>>

Notice how rel= part got chopped and the string has invalid quoting making it unparsable.

berkus commented 8 years ago

Sorry, seems to be my bad - according to this link http://stackoverflow.com/questions/22653420/inserting-meta-using-jade-template-engine i need to add some commas there.

TorbenKoehn commented 8 years ago

Dude, that's actually really interesting.

The first snippets gets parsed correctly in the official Node.js. I didn't even know that you can also separate arguments with a simple space.

I will implement this ASAP.

berkus commented 8 years ago

Cheers! I wondered what's wrong, but apparently in Node it can eat it without commas.

TorbenKoehn commented 8 years ago

Just a small update on this, I'm at it (It should actually be a really small change in the lexer), but I'm in holidays for like 3 more weeks and I'll push it after that.

It will surely be supported in the future!

TorbenKoehn commented 8 years ago

It's in now.

You can mix attribute separators, it's either any kind of whitespace (space, tab, newline) or a comma.

I also added a test to keep your issue tracked and working correctly. https://github.com/Talesoft/tale-jade/blob/master/Test/AttributeTest.php#L159