2015-06-27 87 views
0

我想输出一个标签是这样的:是否可以在rails link_to中添加没有值的html-attributes?

<a href="#" itemscope class="features__cta button>Stuff</a> 

我知道我可以这样添加HTML的属性标签,但我怎么添加一个没有价值呢?

<%= link_to t('features.cta'), t('features.cta_link') , class: 
'features__cta button', itemprop: "priceSpecification" %> 

回答

0

Boolean attributes

没有价值或零字符串值仍是等效的,所以你可以这样写

<%= link_to t('features.cta'), t('features.cta_link') , class: 
'features__cta button', itemprop: '' %> 
+0

这会在标记中导致itemprop =“”,这是否正确? – Himmators

+0

@Himmators是的。 –

0

您可以添加HTML属性,这样

<%= link_to t('features.cta'), t('features.cta_link') , :class => "Myclass", :itemprop => ""%> 
相关问题