V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
? Learn Python the Hard Way
Python Sites
? PyPI - Python Package Index
? http://diveintopython.org/toc/index.html
? Pocoo
值得关注的项目
? PyPy
? Celery
? Jinja2
? Read the Docs
? gevent
? pyenv
? virtualenv
? Stackless Python
? Beautiful Soup
? 结巴中文分词
? Green Unicorn
? Sentry
? Shovel
? Pyflakes
? pytest
Python 编程
? pep8 Checker
Styles
? PEP 8
? Google Python Style Guide
? Code Style from The Hitchhiker's Guide
reaky
V2EX  ?  Python

求助,bottle template可以直接传HTML吗?

  •  
  •   reaky ·
    reaky · 2012-02-04 23:41:47 +08:00 · 5088 次点击
    这是一个创建于 4478 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我打算写markdown,处理成HTML后传给bottle Simple template,可是全给urlencode了,没有解决办法吗?

    @route('/')
    @view('blog')
    def blog():
    return dict(posts=[('title','<a>post</a>')])

    给转化成了&lt;a&gt;post&lt;/a&gt;

    小弟技术浅薄,望万能的v2exer指教。
    6 条回复  ?  1970-01-01 08:00:00 +08:00
    solos
        1
    solos  
       2012-02-04 23:56:14 +08:00
    试试在模板里变量前面加感叹号,好像遇到过这个问题
    phus
        2
    phus  
       2012-02-05 00:00:08 +08:00
    试下
    @view('blog', template_settings={'noescape':True})
    reaky
        3
    reaky  
    OP
       2012-02-05 00:01:49 +08:00
    @solos 好像不行,SyntaxError: invalid syntax 这么说的
    reaky
        4
    reaky  
    OP
       2012-02-05 00:05:23 +08:00
    @phus 太感谢了,我搞了好几个小时了 之前貌似在哪还看见过这句话来着
    phus
        5
    phus  
       2012-02-05 00:07:26 +08:00
    呵呵,我对bottle也不熟,临时翻bottle.py代码找出来的。发现bottle代码写的非常好,值得学习。
    reaky
        6
    reaky  
    OP
       2012-02-05 00:12:30 +08:00
    @phus 咱水平不够,对代码看了半天也没看出所以然,看来还要加强练功
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5584 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:26 · PVG 15:26 · LAX 00:26 · JFK 03:26
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com