我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用django.template.defaultfilters.yesno()。
def environment(**options): env = Environment(**options) env.install_gettext_translations(translation, newstyle=True) from .templatetags.borgcube import get_url, field_name, compression_name, summarize_archive, job_outcome, format_timedelta, json, describe_recurrence from django.utils.html import escapejs from django.template.defaultfilters import linebreaks, linebreaksbr, yesno env.filters.update({ 'get_url': get_url, # TODO: remove 'field_name': field_name, 'compression_name': compression_name, 'summarize_archive': summarize_archive, 'job_outcome': job_outcome, 'format_timedelta': format_timedelta, 'json': json, 'describe_recurrence': describe_recurrence, 'escapejs': escapejs, 'linebreaks': linebreaks, 'linebreaksbr': linebreaksbr, 'yesno': yesno, }) hook.borgcube_web_jinja_env(env=env) return env
def add_helpers(worksheet, row, column, event, job, helpers, multiple_shifts_format): for helper in helpers: row.next() column.reset() num_shifts = helper.shifts.count() num_jobs = len(helper.coordinated_jobs) format = None if num_shifts + num_jobs > 1: format = multiple_shifts_format worksheet.write(row.get(), column.next(), escape(helper.firstname), format) worksheet.write(row.get(), column.next(), escape(helper.surname), format) worksheet.write(row.get(), column.next(), escape(helper.email), format) worksheet.write(row.get(), column.next(), escape(helper.phone), format) if event.ask_shirt: worksheet.write(row.get(), column.next(), escape(u(helper.get_shirt_display())), format) if event.ask_vegetarian: worksheet.write(row.get(), column.next(), escape(filters.yesno(helper.vegetarian)), format) if job.infection_instruction: worksheet.write(row.get(), column.next(), escape(u( helper.get_infection_instruction_short())), format) worksheet.write(row.get(), column.next(), escape(helper.comment), format)