xml.haml模板动态常量赋值

时间:2015-11-02 19:42:46

标签: ruby xml haml

我正在尝试生成xml.haml模板,但我在%Worksheet{ss:Name="Sheet1"}收到“动态常量赋值”错误。我尝试了很多变化,但都是错误。

!!! XML
%Workbook{xmlns="urn:schemas-microsoft-com:office:spreadsheet", xmlns:o="urn:schemas-microsoft-com:office:office", xmlns:x="urn:schemas-microsoft-com:office:excel", xmlns:ss="urn:schemas-microsoft-com:office:spreadshet", xmlns:html="http://www.w3.org/TR/REC-html40"}
%Worksheet{ss:Name="Sheet1"} 
  %Table
    %Row
      %Cell
        %Data{ss:Type="String"}ID
      %Cell
        %Data{ss:Type="String"}Name
      %Cell
        %Data{ss:Type="String"}Release Date
      %Cell
        %Data{ss:Type="String"}Price
  - @addresses.each do |address|
    %Row
      %Cell
        %Data{ss:Type="Number"}= address.id
      %Cell
        %Data{ss:Type="String"}= address.name
      %Cell
        %Data{ss:Type="String"}= address.released_on
      %Cell
        %Data{ss:Type="Number"}= address.price

翻译此html的正确方法是什么?

修改

我按照建议将样式属性更改为HTML样式。现在,它导出文档,但“由于某种原因无法打开”。这是更新的代码。

!!! XML
%Workbook(xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadshet" xmlns:html="http://www.w3.org/TR/REC-html40")
%Worksheet(ss:Name="Sheet1")
  %Table
    %Row
      %Cell
        %Data(ss:Type="String")ID
      %Cell
        %Data(ss:Type="String")Name
      %Cell
        %Data(ss:Type="String")Email
      %Cell
        %Data(ss:Type="String")Phone
  - @addresses.each do |address|
    %Row
      %Cell
        %Data(ss:Type="Number")= address.id
      %Cell
        %Data(ss:Type="String")= address.company_name
      %Cell
        %Data(ss:Type="String")= address.email
      %Cell
        %Data(ss:Type="Number")= address.phone

0 个答案:

没有答案