1

In Web2py I am creating some email templates and want to include the tag with my css file LOAD'ed into the view. How do I use the LOAD function in the view so that it doesn't use jquery as it is an email and pulls from static, css, base.css. This is what I have now:

<link href="{{=URL('static', 'css/style.css', scheme='http')}}" rel="stylesheet" type="text/css" />

But with this requires that remote content be loaded and most email applications disable this loading. I was wanting to do this:

{{=LOAD(url=URL('static', 'css/style.css', scheme='http'),ajax=False)}}

But it is returning this:

<script type="text/javascript"><!--
web2py_component('http://127.0.0.1:8000/iid_app/static/css/web2py.css','c382784163112');
//--></script><div id="c382784163112">loading...</div>
<script type="text/javascript"><!--
web2py_component('http://127.0.0.1:8000/iid_app/static/css/style.css','c3845864949');
//--></script><div id="c3845864949">loading...</div>

Any ideas on how to make this just include the test from the file?

1 Answer 1

2

If you want to include the content of a CSS file in the email template, just add the following to the template where you want the CSS included:

{{include '../static/css/styles.css'}}

The {{include}} directive looks for the template to be included relative to the application's "views" folder, so the "../" goes up one level from there in the folder structure, and from that point, you can just specify the path to the file you want to include.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.