问题
Write a Script Tag With the Type Application/JSON
This is about as straight-forward as it sounds. I'd like the HAML equivalent of:
<script class="_config" type="application/json">
{
"template": "#myId",
"css": {
"background": "#fff",
"opacity": "0.8"
}
}
</script>
As of now, the only solution is...
%script._config{ type: 'application/json' }
{ |
"template": "#id", |
"css": { "background": "#fff" } |
}
... Which sucks -- it renders the JSON in the page. Also, there should be no need to write the 'multiline' pipes. If its application/json
, why wouldn't HAML know to parse it without normal indentation rules?
Any way to write this without the need of pipe characters?
Thanks!
来源:https://stackoverflow.com/questions/33636072/haml-json-add-a-script-tag-of-type-application-json