Add missing PHP code mixing within <style> tags#350
Add missing PHP code mixing within <style> tags#350osumko wants to merge 2 commits intoatom:masterfrom osumko:patch-1
Conversation
Allow to recognize syntax when embedding php in css style tags within php files, similar to html and js script tags, e.g.:
```
<style type="text/css">
<?php if ( empty( $comments ) ) { ?>
.comments {
display: block;
}
<?php } ?>
</style>
```
|
Thanks @esemlabel! Can you edit the issue body with the pull request template details? The format and information asked for is helpful for anyone that has to review a pull request. |
|
@rsese Pull request was updated a long time ago and should be merged in next batch. I've checked this change on This fixes: microsoft/vscode#33519 |
|
Thanks for the heads up @KapitanOczywisty, there aren't notification for edits so missed the pull request body update (sorry about that @esemlabel!). Now that the PR body has been updated to use the template, I noticed there aren't any tests, is that something you can add @esemlabel? If so, can you drop a comment after that's done so we get a notification?
Just wanted to mention that as with other pull requests, we can't promise any specific timeframe for reviewing or merging a particular PR. |
|
@rsese , what kind of test do you mean? |
|
@esemlabel Something like this, just for language-php/spec/html-spec.coffee Lines 83 to 111 in e3281a8 You can run test in atom using |
|
@KapitanOczywisty, |
|
Done. |
|
VScode team agreed to merge this change in update script downstream. I've checked atom and there is no This pr can be closed, and sorry that I didn't check scopes before I dug out this. |
|
Oh ok no problem, thanks for clarifying - since you're the pull request author @esemlabel does this sound good to you? |
|
I'm good. |
|
Thanks, I'll go ahead and close this out 👍 |
Description of the Change
CSS one of the required languages that can be mixed within PHP files along with HTML and Javascript, needed to embed specific code based on conditions.
HTML mixing
<div><?php echo $title ?></div>and JS mixing<script type="text/javascript"><?php echo $var ?></script>inline or within blocks have been already implemented long time ago. But CSS support for<style>tags still missing.CSS mixing is required only for php type files (php5, phtml, etc.) and only within
<style>tags.Mixing inside .css files, as well as .html and .js, is not allowed.
Alternate Designs
The only way to mixing css styles without breaking syntax highlighting is to duplicate whole
<style>tags with different content or force to use external stylesheets, which is not always applicable when using templates, MVC pattern, when avoiding render blocking, etc.Benefits
PHP parser not depends on IDE or any editor syntax highlighting. But this pull request adds support for correct syntax recognizing inside Atom, VS Code and many other editors that uses Atom's grammar, which needed for syntax linters, intellisense, code snippets and suggestions to work as well inside mixing content.
Possible Drawbacks
VS Code, for which this pull request was made initially, uses modified grammar rules.
VS Code rule
L:(source.css - (meta.embedded.block.php | meta.embedded.line.php))can be loaded from /php/ folder extension, but Atom rules may require modifications to work only within php files. This may besource.css.embedded.htmlif there is exists one.Applicable Issues
None.
Example