First of all, to make things clear, I know I can include my css file by
{{ HTML::style('css/myStyle.css') }}
Which the html to be generated will be:
<link rel="stylesheet" type="text/css" href="http://myhost/public/css/myStyle.css">
The problem is that my view file is used for email and many email client don't load external css file. So I need to make it something like:
<style>
.content-of-my-css {
//content of my css
}
// more css
</style>
As the css settings will be used for multiple email template, I don't want to hard code it. In pure PHP, this can be done by (reference)
<style><?php include "path/to/my/css";?></style>
However, when I do that with laravel, it says:
ErrorException (E_ERROR) include(): http:// wrapper is disabled in the server configuration by allow_url_include=0
So, is there a way I can embed the css in laravel? (I am using laravel 4.2)
It appears that you are using a URL instead of the local file path.
For example
include('http://example.com/css/styles.css');
will produce your error but the following should not
include(public_path().'css/styles.css');
if you are using multiple template i will suggest you to create multiple style views which contain just css and you can include them with blade @include
style1.blade.php
style2.blade.php
in styles just put css code
<style>
.content-of-my-css {
//content of my css
}
// more css
</style>
in master.blade.php layout
<html>
<head>@include('style1')</head>
</html>
if it is dynamic you can pass style parameter
@include($style)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With