我有枝条代码
<script type="text/javascript">
$(document).ready(function() {
$('#{{ setting.name|e }}').editable({
{% if setting.options is not empty %}
source: {{ setting.options|raw }},
{% endif %}
value: '{{ setting.value|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""})|raw}}',
placement: 'bottom',
pk: '{{ setting.id }}',
url: '{{ siteUrl('/admin/settings/edit/' ~ setting.id ) }}',
ajaxOptions: {type: 'post'}
});
});
</script>
此代码
value: '{{ setting.value|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""})raw}}'
在textarea 中输入html标签时,无法正常工作
value: ' <div id="disqus_thread"></div>'
应
value: ' <div id="disqus_thread"></div>;
我如何解决问题?
答案 0 :(得分:2)
设置:
value: '{{ setting.value|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""})|raw}}'
您忘记在|
之前设置raw
。
编辑: 这是工作。我设定了这个:
{% set val = "sdfg sdfg sdfg
s dfg
<p>
sd fg
</p>" %}
{{ val }}
输出:
sdfg sdfg sdfg
s dfg
<p>
sd fg
</p>
集:
{% set val = "sdfg sdfg sdfg
s dfg
<p>
sd fg
</p>" %}
{{ val|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""})|raw }}
输出:
sdfg sdfg sdfgs dfg<p> sd fg </p>