boatyaya
V2EX  ›  Django

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

  •  
  •   boatyaya · May 30, 2017 · 2965 views
    This topic created in 3271 days ago, the information mentioned may be changed or developed.

    有这么一个需求,自定义一个模板标签,返回一段 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'])
            ```
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5458 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 05:53 · PVG 13:53 · LAX 22:53 · JFK 01:53
    ♥ Do have faith in what you're doing.