V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
boatyaya
V2EX  ›  Django

如何在自定义模板标签里使用内建模板标签?

  •  
  •   boatyaya · 2017-05-30 12:45:51 +08:00 · 2404 次点击
    这是一个创建于 2494 天前的主题,其中的信息可能已经有所发展或是发生改变。

    有这么一个需求,自定义一个模板标签,返回一段 html,想在这段 html 里面使用内建的或者其它自定义模板标签。该如何使用?像下面的 cycle, static 标签。在 F12 下,这些内建标签是不 work 的,求思路

    html += '''<div class="{{% cycle 'replyBoxOdd' 'replyBoxEven bg2' %}}">
                        <div class="replyContent {{% cycle 'fltlft' 'fltrt' %}} fs14">
                            <span><a class="blueA commentator" href="#" data-id="{reply_id}" title="点击回复 TA 的留言">{reply_username}</a> 回复说:{reply_comment}</span>
                        </div>
                        <div class="replyerAvatar {{% cycle 'fltrt' 'fltlft' %}}">
                            <img class="ctavatar" src="{{% gravatar_url reply.email %}}" width="63" height="63" onerror="this.src='{{% static 'site/v1/img/davatar.png' %}}'">
                        </div>
                        <div class="clearfloat"></div>
                    </div>
            '''.format(reply_id=item['id'], reply_username=item['username'], reply_comment=item['comment'])
            ```
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4626 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:04 · PVG 18:04 · LAX 03:04 · JFK 06:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.