我有一个 smarty 模板代码如下,我想将 smarty 模板数据逐行写入文本文件。为此,我必须在每条记录的末尾插入一个换行符(即在 value 之后$user_test_result.test_result_data.total_obtained_marks
)。这应该如何实现?请帮我解决这个问题。提前致谢。
{if $all_user_test_result}{assign var='sr_no' value=1}{foreach from=$all_user_test_result item=user_test_result key=key}{if $key!='sort_user_name' && $key!='sort_total_obtained_marks' && $key!='sort_no_correct_answers' && $key!='sort_no_wrong_answers' && $key!='sort_no_skipped_questions'}{$sr_no};{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_user_data.user_name};{else}{$user_test_result.test_user_data.user_name};{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_user_data.test_user_time_used};{else}--{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_correct_answers};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_wrong_answers};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_skipped_questions};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.total_obtained_marks};{else}-{/if}{/if}{assign var='sr_no' value=$sr_no+1}{/foreach}{else}Result not found{/if}