나는 구글 앱 엔진 파이썬 코드에서이를 밀어 여러 줄의 index.html을에서GAE + 자바 스크립트 밀어 :
class ABC(db.Model):
StringA = db.StringProperty()
StringB = db.StringProperty(multiline=True)
abcs = ABC.all()
template_values = {'abcs': abcs,}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
이,
<script type="text/javascript">
var string_A = [];
var string_B = [];
{% for abc in abcs %}
string_A.push("{{ abc.StringA }}");
string_B.push("{{ abc.StringB }}"); //This doesn't work?
{% endfor %}
</script>
내 질문은에 어떻게 다중 행을 배열에 푸시 ??
미리 감사드립니다.
멀티 라인은 Javascript에서 다소 까다 롭습니다. string_B에서 '\ n'을 '\'로 바꾸면 작동합니다. – systempuntoout
\ n을 바꾸는 것만으로 개행 문제를 해결할 수 있지만 다른 문자 (예 : 할당 부호) 및 잠재적 인 XSS 취약성이 남습니다. – ehabkost