Tag: slim lang

rails slim indent语法错误

我正在尝试设计我的网站EULA页面内容,并且我一直收到此错误: 您是否尝试将子标记嵌套在包含文本的标记中? 使用| 对于文本块! 似乎所有我的缩进都很好,但这不起作用: v#page_content .container = render ‘leftbar’ .content = render ‘actions’ .maincol h2 Corp End User License Agreement h7 Last Revised: September 20, 2012 ol li h2 u Introduction | Welcome to the Corp platform at a href=”http://www.Corp.com” www.Corp.com | owned and operated by Social Paragraph Ltd. and/or its affiliates (” b […]

如何在链接中放置图像?

我正在尝试一些非常简单的东西,在我想要的文本和图像链接中。 = link_to ‘NVidia Graphics’, inventory_url, class: ‘lato’ do = image_tag ‘https://stackoverflow.com/questions/18117191/how-to-place-an-image-inside-of-a-link/list-highlighter.png’ 我希望输出类似于: NVidia Graphics 如何使用Slim实现这一目标? 我当前的代码导致网站崩溃。 用于“ http://foobar.comhttps://stackoverflow.com/inventory ”的未定义方法`stringify_keys’:字符串

使用Rails和Slim自定义Javascript类型

在Rails中,javascript_tag和javascript_include_tag都将type属性呈现为 类型= “文本/ JavaScript的” 我需要自定义此属性。 我们的应用程序使用Slim语法,这使得这更加困难。 script src =“mathjax_config”type =“text / x-mathjax-config” ^没有错误,但甚至不包括文件 javascript_tag [type =“text / x-mathjax-config”] javascript代码在这里 ^抛出错误 我希望避免让文件远离苗条。 Ruby版本1.9.3 Rails版本3.2.3

修剪模板 – 删除块标记周围的空格

我在一个新项目中尝试Slim模板(在使用Haml很长一段时间后)。 虽然整体体验很棒,但我遇到的问题是,空格总是插在通常使用display: block标签周围 说, ul.ampm li.am am li.pm pm 生成 am pm 而 .ampm span.am am span.pm pm 生成 ampm 通常这不是一个大问题,但我们使用响应式布局应用display: inline-block to li tags; 显然,它们之间有空格会破坏布局。 我知道 Slim::Engine.options[:pretty] = true 选项(打开它会删除有问题的空白),但它会使所有生成的源难以阅读,而不仅仅是我想要修复的部分。 Slim中的<和>似乎与我需要的相反 – 它们旨在用于在内联标签周围添加空格。 所以… 是否有可能删除Slim中单个块标签周围的空白,类似于HAML空白食客? (没有关闭漂亮选项的影响,那是) 如果不是,它是一个基本的Slim限制(“设计”)或路线图中的某些东西,将来可能实施吗? 非常感激。

Kaminari生成字符串而不是html

十一月有这样的问题,但没有给出答案。 Kaminari在制作中生成字符串而不是html。没有来自作者的反馈,缺乏声誉并没有给我机会在那里提出问题,我的问题也有点不同。 我正在使用Rails 4.2.4,Kaminari 0.16.3和slim作为我的模板语言。 分页导航正确生成,但= paginate @articles生成ALMOST字符串而不是html。 所以它是转义标记,并像常规文本一样显示它们(第一个UL元素除外) <li class="active"><a remote="false">1</a></li><li><a rel="next" href="/?locale=en&amp;page=2">2</a></li><li><a rel="next" href="/?locale=en&amp;page=2">Next › </a></li><li><a href="/?locale=en&amp;page=2">Last &raquo;</a></li> 它运行在瘦服务器和ruby 2.2.2p95(2015-04-13修订版50295)上。 这是第一次发生。 我接下来尝试了:== paginate @articles raw(paginate @articles)htmlentities gem CGI 提前感谢您的回答。

将html.slim视图转换为html.erb – Rails,Slim,ERB

尝试将* .html.slim视图转换为* .html.erb 。 我看过这两个问题: 如何将html.slim转换为html.erb? – 从控制台调用时获取uninitialized constant 如何将html.slim文件转换为html或html.erb? – 解析器遇到NoMethodError: undefined method image_tag for nil:NilClass遇到第一个= image_tag 。 我没有在我的调用中使用任何变量,图像标记指向和svg 如果Stack Overflow的优秀人员可以帮我找出image_tag问题,我认为后一种解决方案效果最好。 我的代码(根据要求): page data-id=”foo-page” .container = image_tag ‘bar.svg’

将ERB模板转换为SLIM

我的很多观点都是SLIM模板,我希望在我的应用程序中添加一个部分的vote_form 。 如何将此部分视图从ERB转换为SLIM? Votes: 谢谢 :)

为什么不能显示餐馆名单?

我正在尝试做一些餐馆名单。 我关联了两个表,然后编写此代码。 class Restaurant < ActiveRecord::Base has_many :restaurant_translations end class RestaurantTranslation < ActiveRecord::Base self.table_name = 'restaurant_translations' end restaurant_controller.rb class RestaurantController < ApplicationController def list @restaurants = Restaurant.all logger.debug @restaurants end end list.html.slim table thead tr th Type th Name of Url th Genre th Addr tbody – @restaurants.each do |restaurant| tr td = restaurant.restaurant_type td […]

jekyll共享模板的不同参数

我试图在其他2个模板中共享一个模板,如下所示: _layouts/V2/post.slim {% include V2/date_wrapper.html date_value=page.date %} 和 _includes/V2/footer/recent_posts.slim | {% for post in site.posts limit: 5 %} | | {{ post.title }} | | | {% include V2/date_wrapper.html date_value=post.date %} | | | {% endfor %} 这是共享模板: _includes/V2/date_wrapper.html {% assign d = include.date_value | date: “%-d” %} {{ include.date_value | date: “%B” }} {% […]

在Ruby脚本中使用SLIM / HAML等?

我目前正在编写一个脚本,分析一些遗传数据,然后在彩色Word文档上生成输出。 但是,脚本工作正常,脚本中的一个方法编写得很糟糕,即创建Word文档的方法。 创建文档的方法创建一个独立的HTML文件,然后使用’docx’扩展名保存,这允许我为文档的不同部分提供不同的样式。 以下是实现此function的最低要求。 它包括一些示例输入数据,这些数据将在最后一步之前以不同的方法创建并存储在散列中,以及必要的方法。 require ‘bio’ def make_hash(input_file) input_read = Hash.new biofastafile = Bio::FlatFile.open(Bio::FastaFormat, input_file) biofastafile.each_entry do |entry| input_read[entry.definition] = entry.aaseq end return input_read end def to_doc(hash, output, motif) output_file = File.new(output, “w”) output_file.puts ” .id{font-weight: bold;} .signalp{color:#000099; font-weight: bold;} .motif{color:#FF3300; font-weight: bold;} h3 {word-wrap: break-word;} p {word-wrap: break-word; font-family:Courier New, Courier, Mono;}” hash.each […]