openerp所用QWEB2的调试笔记
2017-10-30 08:10:00 作者: Administrator 来源:互联网,版权归作者所有 浏览次数: 1,281 文字大小:【大】【中】【小】
你没有登录,文章中的图片无法正常显示,请点击登录。
〈t t-log="变量名称" /> 〈t t-log=" '变量名称的说明' " />
〈t t-debug="随便什么东东" />
1】 调式qweb模板时, 可以脱离openerp环境
阅读一下openerp目录 qweb目录中的几个html文件,可以作为起步
在浏览器下, 可以这样运行这些文件
http://127.0.0.1:8069/web/static/lib/qweb/qweb-benchmark.html
http://127.0.0.1:8069/web/static/lib/qweb/qweb-test.js.html
【2】qweb模板的格式如果不符合xml规范, 浏览器显示空白, 浏览器的控制台中会显示如下提示
Uncaught Error: QWeb2: This page contains the following errors:error on
line xxx at column yyy:
然后是具体的错误原因。比如
Opening and ending tag mismatch: aaa line nnn and bbb
Specification mandate value for attribute ccc
【3】在模板中增加如下指令, 可在浏览器的控制台上输出变量内容
当使用多个t-log时, 控制台中输出的变量内容会引起混淆, 这时可再增加如下语句
【4】在模板中增加如下指令, 可在qweb的编译模板过程中进入断点语句,
这时, 我们可以在控制台的源码页签中看到编译的中间过程,
在控制台下, 使用console.log(dict) 可以看到传入的所有参数
使用console.log(r) 可以看到输出中间结果
官方文档上 介绍的使用方法 〈t t-debug /> ,如果后面不随便添加些什么东东, 会出现如下错误
Specification mandate value for attribute t-debug
【5】模板文件示例 (在qweb目录下, 文件名为 laoliu.xml)
如下是官网上web文档中的例子, 增加了t-log和t-debug语句
|
【6】 程序示例 (在qweb目录下, 文件名为 laoliu.html)
访问方法:http://127.0.0.1:8069/web/static/lib/qweb/laoliu.html
|
【7】t-debug的运行结果
) {
r.push(context.engine.tools.gen_attribute(['class',
('base ' + (dict['cls']))]));
r.push('>
'n
console.log('in example_template, value of
[items]:');
r.push('n
console.log(dict['items']);
r.push('n
if (dict['title']) {
r.push(' 〈h4>
r.push(context.engine.tools.html_escape(dict['title']));
r.push(' 〈/h4>
}
r.push('n
'n
context.engine.tools.foreach(context,
dict['items'], 'item', dict, function(context, dict) {
r.push(' 〈li');
r.push(context.engine.tools.gen_attribute(['class',
(dict['item_parity'])]));
r.push('>
'n
r.push(context.engine.tools.call(context,
'example_template.sub', dict, '', function(context, dict) {
var r = [];
r.push('n
dict['arg'] = (dict['item_value']);
r.push('n
return r.join('');
}));
r.push('n
});
r.push('n
'n
debugger;
r.push('n
}) |
相关文章
评论
服务原则及地区范围
宜兴通达团队,在企业网络维护和企业信息化建设与咨询方面,有10多年经验。
我团队愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!
通达团队提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。
宜兴地区提供上门服务:
- 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
- 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。