如何让厨师模板有一个“[”?

时间:2014-10-10 02:40:58

标签: templates chef

我想要使用chef模板生成Django settings.py文件。但看起来像settings.py中的list对象总是让厨师陷入困境:

这是模板的源代码:

 91: # DNS configurations
 92: DEFAULT_NAMESERVERS = [ 
 93: <% @nameservers.each do |ns| %>
 94: '<%=#{ns}%>',
 95: <% end %>
 96: ] 
 97: 

我总是收到以下错误消息:

 * template[/var/www/pdnsrestserver/pdnsrestserver/settings.py] action create

    ================================================================================
    Error executing action `create` on resource 'template[/var/www/pdnsrestserver/pdnsrestserver/settings.py]'
    ================================================================================

    Chef::Mixin::Template::TemplateError
    ------------------------------------
    **(erubis):96: syntax error, unexpected ']', expecting ')'**
     _buf << '] 
               ^
    (erubis):172: syntax error, unexpected '}', expecting ')'

1 个答案:

答案 0 :(得分:0)

我确实认为你缺少空间并且在引用的字符串之外有一个插值代码

我认为这样可行:

 91: # DNS configurations
 92: DEFAULT_NAMESERVERS = [ 
 93: <% @nameservers.each do |ns| %>
 94: '<%= ns %>',
 95: <% end %>
 96: ] 
 97: 

未经测试的代码