V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Feb 4, 2012 · 6120 views
    This topic created in 5203 days ago, the information mentioned may be changed or developed.
    我打算写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 replies    1970-01-01 08:00:00 +08:00
    solos
        1
    solos  
       Feb 4, 2012
    试试在模板里变量前面加感叹号,好像遇到过这个问题
    phus
        2
    phus  
       Feb 5, 2012
    试下
    @view('blog', template_settings={'noescape':True})
    reaky
        3
    reaky  
    OP
       Feb 5, 2012
    @solos 好像不行,SyntaxError: invalid syntax 这么说的
    reaky
        4
    reaky  
    OP
       Feb 5, 2012
    @phus 太感谢了,我搞了好几个小时了 之前貌似在哪还看见过这句话来着
    phus
        5
    phus  
       Feb 5, 2012
    呵呵,我对bottle也不熟,临时翻bottle.py代码找出来的。发现bottle代码写的非常好,值得学习。
    reaky
        6
    reaky  
    OP
       Feb 5, 2012
    @phus 咱水平不够,对代码看了半天也没看出所以然,看来还要加强练功
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2803 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 14:52 · PVG 22:52 · LAX 07:52 · JFK 10:52
    ♥ Do have faith in what you're doing.