1. erb文件中的语法说明

erb文件中常混合使用Ruby语言和html语言,以下为两种常见的格式

  • <% 写逻辑脚本(Ruby语法) %>
  • <%= 直接输出变量值或运算结果 %>
    require "erb"  
    domains = {...}  
    sqlTemplate = ERB.new %q{  
    <%for organization in domains.keys%>  
        insert into org_domain(Domain, organization) values('<%=domains[organization]%>','<%=organization%>');  
    <%end%>  
    }  
    sqlFile = File.new("./sql.sql", "w")  
    sqlFile.puts sqlTemplate.result  

 

相关文章:

  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
猜你喜欢
  • 2021-07-11
  • 2021-06-04
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案