我正在尝试在细长的部分中安装一些再营销代码,并且在测试中,输出看起来不太合适。
这是我给出的javascript:
<!-- Google Code for Remarketing Tag -->
<!--------------------------------------------------
Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup
--------------------------------------------------->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = my_id_here;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/my_id_here/?guid=ON&script=0"/>
</div>
</noscript>
这就是我要将其转换为(通过Sublime中的HTML2Slim包)
- if Rails.env.development?
/! Google Code for Remarketing Tag
/!
| \------------------------------------------------
| Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup
| \-------------------------------------------------
javascript:
/!* */
| var google_conversion_id = my_id_here;
| var google_custom_params = window.google_tag_params;
| var google_remarketing_only = true;
/!* */
script src="//www.googleadservices.com/pagead/conversion.js" type="text/javascript"
noscript
div style="display:inline;"
img alt="" height="1" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/my_id_here/?guid=ON&script=0" style="border-style:none;" width="1" /
当我在开发中运行它时,这是DOM中的输出
<!--Google Code for Remarketing Tag--><!--| \------------------------------------------------
| Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup
| \--------------------------------------------------->
<script>
/!* */
| var google_conversion_id = my_id_here;
| var google_custom_params = window.google_tag_params;
| var google_remarketing_only = true;
/!* */
</script>
<script src="//www.googleadservices.com/pagead/conversion.js" type="text/javascript"></script><noscript><div style="display:inline;"><img alt="" height="1" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/my_id_here/?guid=ON&amp;script=0" style="border-style:none;" width="1" /></div></noscript>
除了以下几点外,一切似乎都很好:
/* <![CDATA[ */
和/* ]]> */
行(非常确定Google会需要这些。type="text/javascript"
属性,但我猜这不会太重要所以我的问题是,如何确保/* <![CDATA[ */
和/* ]]> */
使用苗条语言进行呈现OR是否有办法逃避此文件中的语言并放入原始的javascript块?
答案 0 :(得分:0)
想出来。只是使用简单的|
来表示“逐字文字”。它就像Slim语言最基本的语法规则。
这里的代码最终看起来像:
javascript:
| /* <![CDATA[ */
| var google_conversion_id = my_id_here;
| var google_custom_params = window.google_tag_params;
| var google_remarketing_only = true;
| /* ]]> */
DERP。苗条的超级好看