Ruby 透過 Google API 串接 Excel (SpreadSheet)
本文章將一步一步教學如何透過 ruby ...
def html_body_attributes content_for?(:body_attributes) ? ::Nokogiri::XML("<x>#{content_for(:body_attributes)}</x>").xpath('//x').first.children.each_with_object({}) { |node, obj| obj[node.name] = node.text } : {} end
body class=(yield :body_classes) *html_body_attributesclass=(yield :body_classes) 的部份可以忽略,因為我個人會把 <body> class 獨立出來用別的方式給值。
- content_for(:body_attributes) do data-turbolinks="false" data-lazy-loading="true"每個 attribute 之間需要換行,slim 會以 xml 格式輸出,helper 中再 parse XML 以 ruby hash 輸出即可。