html - 在 web2py 中加载静态文件

标签 html css include web2py

在 Web2py 中,我正在创建一些电子邮件模板,并希望将标签与加载到 View 中的 css 文件一起包含在内。 我如何在 View 中使用 LOAD 函数,以便它不使用 jquery,因为它是一封电子邮件并从静态、css、base.css 中提取。 这就是我现在拥有的:

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

但是这需要加载远程内容并且大多数电子邮件应用程序禁用此加载。 我想这样做:

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

但它返回的是:

<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>

关于如何只包含文件中的测试有什么想法吗?

最佳答案

如果您想在电子邮件模板中包含 CSS 文件的内容,只需将以下内容添加到您希望包含 CSS 的模板中:

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

{{include}} 指令查找要包含的相对于应用程序“views”文件夹的模板,因此“../”在文件夹结构中从那里上升一级,从那时起,您只需指定要包含的文件的路径即可。

关于html - 在 web2py 中加载静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13402152/

相关文章:

html - 在 Safari 中看不到 boxshadow

javascript - vanilla javascript/HTML中的空导出{}是什么意思

html - Div 底部的中心三 Angular 形

javascript - 为什么 Onblur 不起作用(JQuery/Javascript)

css - 事件状态不适用于 CSS Sprite

php - 为什么 PHP "require"找不到文件?

javascript - 向下滑动时反转 slider

html - 按钮的最小 Bootstrap css

ruby-on-rails - 如何正确地重写模块混入的方法?

php - 无法访问包含文件中的全局变量