HAML | JSON: Add a Script Tag of Type Application/JSON

北战南征 提交于 2019-12-11 11:32:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!