Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 防止Slim解析内部代码<;脚本>-标签_Ruby_Handlebars.js_Slim Lang_Ractivejs - Fatal编程技术网

Ruby 防止Slim解析内部代码<;脚本>-标签

Ruby 防止Slim解析内部代码<;脚本>-标签,ruby,handlebars.js,slim-lang,ractivejs,Ruby,Handlebars.js,Slim Lang,Ractivejs,我在sinatra应用程序中使用slim作为模板,在客户端使用ractive.js类似把手的语法 我将模板代码保存在script标记中,但slim试图像解析文件的其余部分一样解析它们。我的简化代码如下所示: section.header-section h1 Items section.main-section script#items type="text/html" <ul class="items"> {{#each items}} <li&g

我在sinatra应用程序中使用
slim
作为模板,在客户端使用
ractive.js
类似把手的语法

我将模板代码保存在
script
标记中,但slim试图像解析文件的其余部分一样解析它们。我的简化代码如下所示:

section.header-section
  h1 Items
section.main-section
script#items type="text/html"
  <ul class="items">
    {{#each items}}
      <li>{{title}}</li>
    {{/each}}
  </ul>
这没用。因此,我需要
slim
忽略
script
中的所有内容,保留缩进以提高可读性。唯一可能的解决方案是创建我自己的嵌入式引擎,并且在里面什么都不做。还有其他方法可以修复它吗?

您可以使用:

script#items type=“text/html”
|
    {{{#每项}
  • {{title}}
  • {{/每个}}
产生:

    {{{#每项}
  • {{title}}
  • {{/每个}}

谢谢,这正是我需要的!
set :slim, {:pretty => true, :attr_list_delims => {'(' => ')', '[' => ']'}, :code_attr_delims => {'(' => ')', '[' => ']'}}
script#items type="text/html"
  |
    <ul class="items">
      {{#each items}}
        <li>{{title}}</li>
      {{/each}}
    </ul>