fix: テンプレートへの埋込時にクォートがおかしくなる問題を修正

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-07-28 09:17:31 +09:00
parent aacbeb9687
commit b6468a45dc
2 changed files with 5 additions and 2 deletions

View File

@ -61,7 +61,10 @@ class BioViewModel(BaseModel):
# 呼び出し一回あたりの分割数 # 呼び出し一回あたりの分割数
part_size = 500 part_size = 500
for i in range(0, search_data_len, part_size): for i in range(0, search_data_len, part_size):
yield json.dumps(search_data_list[i:i + part_size], ensure_ascii=False, default=date_handler) json_str = json.dumps(search_data_list[i:i + part_size], ensure_ascii=False, default=date_handler)
# テンプレートに埋め込むため、ダブルクォートをエスケープして返す
json_str = json_str.replace('"', '\\"')
yield json_str
def make_whs_name(self): def make_whs_name(self):
if not self.is_form_submitted(): if not self.is_form_submitted():

View File

@ -340,7 +340,7 @@
// {% autoescape False%} // {% autoescape False%}
// ジェネレータで100件ずつ取ってリストに詰める // ジェネレータで100件ずつ取ってリストに詰める
// {% for bio_data_json_str in bio.bio_data_json_str() %} // {% for bio_data_json_str in bio.bio_data_json_str() %}
searchResultData.push(...JSON.parse('{{bio_data_json_str}}')) searchResultData.push(...JSON.parse("{{bio_data_json_str}}"))
// {% endfor %} // {% endfor %}
// {% endautoescape%} // {% endautoescape%}
// {% endif %} // {% endif %}