免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2555 | 回复: 1

mako的def 和namespace使用中遇到的输出换行问题 [复制链接]

论坛徽章:
0
发表于 2010-05-03 23:54 |显示全部楼层
根据官方提供的namespace的例子

我把index.html的内容无论是print 还是使用file生成到文件里面,都会自动换行

components.html
  1. ## components.html
  2. <%def name="comp1()">
  3.     this is comp1
  4. </%def>

  5. <%def name="comp2(x)">
  6.     this is comp2, x is ${x}
  7. </%def>
复制代码
index.html
  1. <%namespace name="comp" file="components.html"/>

  2. Heres comp1:  ${comp.comp1()}
  3. Heres comp2:  ${comp.comp2(x=5)}
复制代码
结果


Heres comp1:
    this is comp1

Heres comp2:
    this is comp2, x is 5


哪位用过mako的def和namespace的同学指点下?

论坛徽章:
0
发表于 2010-05-04 08:32 |显示全部楼层
Heres comp1:
    this is comp1

Heres comp2:
    this is comp2, x is 5

yangward 发表于 2010-05-03 23:54

这是print的结果  还是浏览器里看到的结果? html文件里有换行没什么影响,浏览器又不解释换行。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP