I was just editing a tsv row template for a tsv download format we provide. The template contains a single 3068 character line, which is really hard to edit:
{% load customtags %}{% get_many_related_rec row.labels row.peak_group_label as label_recs %}{{ row.msrun_sample.sample.name }} {{ row.msrun_sample.sample.tissue.name }} {{ row.msrun_sample.sample.time_collected|durationToMins }} {{ row.name }} {% for mcpd in row.compounds.all %}{% if not forloop.first %};{% endif%}{{ mcpd.name }}{% endfor %} {% for mcpd in row.compounds.all %}{% if not forloop.first %};{% endif%}{% get_case_insensitive_synonyms mcpd.synonyms as inssyns %}{% for mcpdsyn in inssyns %}{% if not forloop.first %}/{% endif%}{{ mcpdsyn }}{% endfor %}{% endfor %} {{ row.formula }} {% for label_rec in label_recs %}{% if not forloop.first %},{% endif %}{{ label_rec.element }}{% endfor %} {% for msrsrec in row.msrun_sample.sample.msrun_samples.all %}{% if msrsrec.ms_data_file %}{% if mzxml_exists %}, {% endif %}{% define True as mzxml_exists %}{{ msrsrec.ms_data_file.filename }}{% endif %}{% endfor %}{% if pg.msrun_sample.sample.msrun_samples.count == 0 or pg.msrun_sample.sample.msrun_samples.count == 1 and pg.msrun_sample.sample.msrun_samples.first.ms_data_file is None %}None{% endif %} {{ row.total_abundance }} {% for label_rec in label_recs %}{% if not forloop.first %},{% endif %}{{ label_rec.enrichment_fraction }}{% endfor %} {% for label_rec in label_recs %}{% if not forloop.first %},{% endif %}{{ label_rec.enrichment_abundance }}{% endfor %} {% for label_rec in label_recs %}{% if not forloop.first %},{% endif %}{% if label_rec.normalized_labeling is None %}None{% else %}{{ label_rec.normalized_labeling }}{% endif %}{% endfor %} {{ row.peak_annotation_file.filename }} {{ row.msrun_sample.sample.animal.name }} {{ row.msrun_sample.sample.animal.genotype }} {{ row.msrun_sample.sample.animal.body_weight }} {{ row.msrun_sample.sample.animal.age|durationToWeeks }} {{ row.msrun_sample.sample.animal.sex }} {{ row.msrun_sample.sample.animal.diet }} {{ row.msrun_sample.sample.animal.feeding_status }} {% if row.msrun_sample.sample.animal.treatment is None %}None{% else %}{{ row.msrun_sample.sample.animal.treatment.name }}{% endif %} {% if row.msrun_sample.sample.animal.infusate.short_name is None %}None{% else %}{{ row.msrun_sample.sample.animal.infusate.short_name }}{% endif %} {% for link in row.msrun_sample.sample.animal.infusate.tracer_links.all %}{% if not forloop.first %};{% endif%}{% if link.tracer.name is None %}None{% else %}{{ link.tracer.name }}{% endif %}{% endfor %} {% for link in row.msrun_sample.sample.animal.infusate.tracer_links.all %}{% if not forloop.first %};{% endif%}{% if link.tracer.compound.name is None %}None{% else %}{{ link.tracer.compound.name }}{% endif %}{% endfor %} {% for link in row.msrun_sample.sample.animal.infusate.tracer_links.all %}{% if not forloop.first %},{% endif%}{% if link.concentration is None %}None{% else %}{{ link.concentration }}{% endif %}{% endfor %} {{ row.msrun_sample.sample.animal.infusion_rate }} {% for study in row.msrun_sample.sample.animal.studies.all %}{% if not forloop.first %}, {% endif%}{{ study.name }}{% endfor %}
It’s used as the rowtmplt
in this generator:
def tsv_template_iterator(rowtmplt, headtmplt, res, qry, dt):
yield headtmplt.render({"qry": qry, "dt": dt})
for row in res:
yield rowtmplt.render({"qry": qry, "row": row})
Is there any way I can have a template with hard returns in it that aren’t rendered, just to make it easier to deal with?