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

Inline CSS always commented by HeadStyle ViewHelper #165

Open
tworzenieweb opened this issue Aug 20, 2018 · 2 comments
Open

Inline CSS always commented by HeadStyle ViewHelper #165

tworzenieweb opened this issue Aug 20, 2018 · 2 comments

Comments

@tworzenieweb
Copy link

tworzenieweb commented Aug 20, 2018

It looks like the inline style definition is not correctly printed by HeadStyle view helper.

Considering the following one:

<?php $this->headStyle()->captureStart(); ?>
@media only screen and (max-width: 620px) {

div[class*="pd-left20"]{padding:0 0 0 20px !important;}
td[class*="resetPadding"]{padding:0 0 0 0 !important;}
td[class*="padding20"]{padding:20px 0 20px 0 !important;}

}
<?php $this->headStyle()->captureEnd(); ?>

The whole block will be commented out.

I tried disabling auto escaper but escaping is hardcoded into HeadStyle implementation.

Actually, after a deep look in the code, I don't get why CSS content is always commented via <!-- -->:

[0]

 $html = '<style type="text/css"' . $attrString . '>' . PHP_EOL
            . $escapeStart . $indent . $item->content . PHP_EOL . $escapeEnd
            . '</style>';

$escapeStart and $escapeEnd can be null only for conditional CSS which is not a regular use case.

The examples from documentation are giving me similar commented output. [1]

[0] https://github.com/zendframework/zend-view/blob/master/src/Helper/HeadStyle.php#L328
[1] https://docs.zendframework.com/zend-view/helpers/head-style/#capturing-style-declarations

@froschdesign
Copy link
Member

@tworzenieweb

The whole block will be commented out.

The comments are used for backward compatibility in old browsers and are ignored by CSS.

But today these comments are obsolete and can be removed without problems.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-view; a new issue has been opened at laminas/laminas-view#6.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants