简体   繁体   English

宝石绿猴 - 导轨

[英]Gem Green Monkey - Rails

Has anyone used " Green Monkey " to create an HTML-layout with microdata properties?有没有人使用“ Green Monkey ”创建具有微数据属性的 HTML 布局?

I'm struggling to understand how to go from Haml to Html.erb, according to the documentation.根据文档,我正在努力了解如何从 Haml 到 Html.erb 的 go 。 For example, I haven't figured out the Haml %span[:name]= item.name .例如,我还没有弄清楚 Haml %span[:name]= item.name

I get most of it except [:name] .除了[:name]之外,我得到了大部分。

How do I translate this in html.erb?如何在 html.erb 中翻译这个?

Green Monkey adds an extension to Haml. Green Monkey 为 Haml 添加了一个扩展。 The documents display what the input and output look like.文档显示了输入和 output 的样子。

Haml input (assuming item.name is set to 'Item name' ): Haml 输入(假设item.name设置为'Item name' ):

%span[:name]= item.name

HTML output: HTML output:

<span itemprop='name'>Item name</span>

It is taking the value in [] , transforming it into HTML attributes.它采用[]中的值,将其转换为 HTML 属性。 Symbols become itemprop attributes, and Mida objects become itemscope and itemtype attributes. Symbols 成为itemprop属性, Mida对象成为itemscopeitemtype属性。

There is a also a helper the documention mentions above that example, which would work like this:文档在该示例上方提到的还有一个助手,它的工作方式如下:

<span<%=mida_scope(:item)%>><%=item.name%></span>

mida_scope transforms the Mida-aware objects to HTML attributes and outputs those using the Rails tag_builder.tag_options(html_attributes) . mida_scope将 Mida 感知对象转换为 HTML 属性并使用 Rails tag_builder.tag_options(html_attributes)输出这些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM