Closed hax closed 7 years ago
Hi,
prettyprint is not about PHP compilation but as in pug-js, it's for final HTML output. For PHP debugging, I created the phpSingleLine option. You can pass it to true to get a new line for each PHP statement generated.
But I'm agree prettyprint=true
as no real meaning except maybe to display HTML for a demonstration. In production, you should always set it to false. And for inline tags render, use:
span a
span b
To get ab
and:
span a
=" "
span b
To get a b
, or you can also:
| #[span a] #[span b]
This is the recommended syntax for long texts with inline tags inside, like in:
| I'm #[strong happy] to see you.
To come back to prettyprint, it can be handled by an other program to compress or to beautify. But this is a port of pug-js. We try to implement pug-js features as it and adapt them to PHP syntax and possibilities as close as possible to the original pug to provide a standard solution.
It's out of the question to display all tags with PHP. And the priority remains to allow in production (prettyprint=false) all the syntaxes above to be able to display inline tags with or without spaces between.
If I can improve this rendering without break this logic and with no extra PHP code in compiled files, I'll do it; but I will not take the risk to cause regressions. I prefer to keep standard tools as it and provide customizations so if thoses syntaxes and phpSingleLine do not cover your need, please tell me you final goal. I will try to give you the best way to acheive it.
Hi, with the new refactorized version, we will try to be as close as possible as the pug-js results for both pretty and non-pretty options but we will try to provide more customizations.
Hi, there is a new option now available to use the native pugjs engine (until the 3.0):
$pug = new Pug(array(
'pugjs' => true
));
echo $pug->render('
span a
=" "
span b
');
This is a pure wrapper solution with no PHP support in templates (all run with node.js).
You can update to 3.0.0-alpha2
, it should be fixed. Consecutive span are no longer affected by prettyprint option. Please don't hesitate to test the new pug-php 3 and give us your feedback.
This is an old issue of original jade-php (or original jade/pug), but I'd wish it be fixed in pug-php.
Currently, when
prettyprint
isfalse
, all generated code will be compressed to one line which make line position meaningless and make debug painful.IMO
prettyprint=true
have no real use case, especially in PHP. Even in JS, if we want to compress the generated code to save bytes, we could just use tools like uglify.But
prettyprint
affect the output of html in whether it compress whitespace between tags.output
result
ab
ifprettyprint=false
,but output
result
a b
(extra space betweena
andb
) ifprettyprint=true
.In fact, with
prettyprint=true
we have no way to output<span>a</span><span>b</span>
at all.So
prettyprint
is a BAD designed option which not only affect generated code, but also affect html output semantic.I suggest drop this option (at least deprecate it), and make the generated code always multilines.
To achieve that, the generated code should not be
but should be
There are other methods to output the same result, but this transformation may be the easiest.