How do I add multiple arguments to my custom template filter in a django template?

前端 未结 9 551
时光说笑
时光说笑 2020-11-27 12:20

Here\'s my custom filter:

from django import template

register = template.Library()

@register.filter
def replace(value, cherche, remplacement):
    retur         


        
9条回答
  •  盖世英雄少女心
    2020-11-27 12:54

    Heres a bad idea but works:

    {{ xml|input_by_xpath:"{'type':'radio','xpath':'//result/value'}" }}
    

    and

    @register.filter
    def input_by_xpath(device, args): 
        args = eval(args)
        ...
        result = ""%(args['type'],value,args['xpath'])
        return mark_safe(result)
    

提交回复
热议问题