-
Notifications
You must be signed in to change notification settings - Fork 191
2.0 (WIP) #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.0 (WIP) #111
Conversation
…ble. * From now on you can re-use the class for multiple mails. * A lot less complicated options, as in: no more options at all. * More separate classes which handle their own (tested) methods. * A lot more tests The reason why I did this was to made the class more usable.
|
@barryvdh , @stof , @GrahamCampbell would you guys be so kind to have a look at the v2.0.0-PR. It is a major change, but I think it is a nice improvement. Some stuff has been removed, feel free to tell me what is missing, and I will implement it again. Thanks in advance. |
|
The code for the clean-up (cleanup() | doCleanup()) is copy&pasted three times in the project, maybe we can create one method for this task ... maybe it's also a good idea to move the reg-ex into a static variable, so it has a name and we can read it and we can quickly edit/fix it. E.g. the reg-ex for code-comments in the next "globalCleanup()" method covered also comments (/** foobar */) in CSS files. (here is the test: https://github.com/voku/CssToInlineStyles/blob/master/tests/CssToInlineStylesTest.php#L187) /**
* @param $string
* @return mixed|string
*/
protected function cleanup($string)
{
$string = str_replace(array("\r", "\n"), '', $string);
$string = str_replace(array("\t"), ' ', $string);
$string = str_replace('"', '\'', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string);
$string = preg_replace('/\s\s+/', ' ', $string);
$string = trim($string);
$string = rtrim($string, ';');
return $string;
}
protected function cleanup($string)
{
$string = str_replace(array("\r", "\n"), '', $string);
$string = str_replace(array("\t"), ' ', $string);
$string = str_replace('"', '\'', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string);
$string = preg_replace('/\s\s+/', ' ', $string);
$string = trim($string);
$string = rtrim($string, '}');
return $string;
}
/**
* @param $css
* @return mixed|string
*/
protected function doCleanup($css)
{
// remove media queries
$css = preg_replace('/@media [^{]*{([^{}]|{[^{}]*})*}/', '', $css);
$css = str_replace(array("\r", "\n"), '', $css);
$css = str_replace(array("\t"), ' ', $css);
$css = str_replace('"', '\'', $css);
$css = preg_replace('|/\*.*?\*/|', '', $css);
$css = preg_replace('/\s\s+/', ' ', $css);
$css = trim($css);
return $css;
}into --> /**
* @param string $string
* @param string $rtrim
* @param bool $removeMediaQueries
* @return string
*/
protected function globalCleanup($string, $rtrim = '', $removeMediaQueries = false)
{
// remove media queries
if ($removeMediaQueries === true) {
$string = preg_replace('/@media [^{]*{([^{}]|{[^{}]*})*}/', '', $string);
}
// remove newlines & tab to space & replace double quotes by single quotes
$string = str_replace(array("\r", "\n", "\t", '"'),array('', '', ' ', '\''),$string);
// remove comments
$string = preg_replace('/\\/\\*.*\\*\\//sU', '', $string);
// remove spaces
$string = preg_replace('/\s\s+/', ' ', $string);
$string = trim($string);
if ($rtrim) {
$string = rtrim($string, $rtrim);
}
return $string;
} |
|
So what options are now used by default? I usually need the following:
|
composer.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should keep the branch alias IMO (updating it to 2.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be kept (with the update), so that the master branch has the right alias after merging this to master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in de745ff
|
@tijsverkoyen can you describe what is the 1.x equivalent configuration of the new library ? This would help knowing what feature is kept and what is removed |
composer.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also allow phpunit 5, not only 4.8 (4.8 does not officially support PHP 7, even if it mostly works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 2851b4a
* some about style * some about improving the code * some about improving this package
…y is the task of the Processor
|
I think most of the feedback is processed. Could you all test with real examples to see if everything is working as expected? |
|
Tried rendering all the Zurb examples from here: http://foundation.zurb.com/emails/email-templates.html |
[2.0] Use ExceptionInterface instead of SyntaxErrorException
|
@barryvdh thx! |
|
So, this good to go? |
|
@barryvdh if nobody has any remarks anymore ;-) |
|
Perhaps tag it as an |
The 2.0 version is a major overhaul, which is not backwards compatible.
The reason why I did this was to make the class more usable.