-
Notifications
You must be signed in to change notification settings - Fork 650
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
IE conditionals support #27
Comments
This is a known issue with a clean workaround. Marko ignores HTML comments and this breaks IE conditionals since the comments are never written to the output. I've suggested the following workaround in the past: Create a custom tag named module.exports = function render(input, out) {
var lang = input.lang;
out.write(
'<!DOCTYPE html>' +
'<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="' + lang + '"> <![endif]-->' +
'<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="' + lang + '"> <![endif]-->' +
'<!--[if IE 8]> <html class="lt-ie9" lang="' + lang + '"> <![endif]-->' +
'<!--[if !IE]> --><html lang="' + lang + '"><!--<![endif]—>');
input.renderBody(out);
out.write('</html>');
}; Then in your page layout or page template: <app-html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
...
</head>
<body>
...
</body>
</app-html> Output: <!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en-us"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en-us"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en-us"> <![endif]-->
<!--[if !IE]> --><html lang="en-us"><!--<![endif]—>
<head>
<meta charset="UTF-8">
<title>Hello World</title>
...
</head>
<body>
...
</body>
</html> The benefit of this approach is that the HTML template is cleaner. In theory, we could look into a code change to introduce special handling for IE HTML comments. I'm open to ideas and/or Pull Requests, but hopefully the workaround solves your problem for now. |
Fixes #27 - Preserve IE conditional comments
New version published with improvement: |
Hey @patrick-steele-idem, not a big deal, but you may want to update your code sample above to use |
Thanks for letting me know @yomed. IE conditional HTML comments are automatically preserved now so the workaround discussed is not needed. |
I had noticed that even though they are preserved, variables weren't output correctly. I didn't dig into it too much, but I saw this issue and liked your So for example:
Would end up as:
|
That's true, variables inside comments are not resolved. Does keep the template code cleaner as well. Thanks for sharing. |
I am trying to target IE browsers with some simple IE conditionals, but it seem to fail in marko template.
My template has these simple conditionals, but its not getting targeted properly. I don’t see the classes being added. (works however in plain html)
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="${locale}"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="${locale}"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="${locale}"> <![endif]-->
<!--[if !IE]> --><html lang="${locale}"><!--<![endif]—>
anything to do with the HTML comment’s?
The text was updated successfully, but these errors were encountered: