[chef] how do I share common functions between templates


Chronological Thread 
  • From: < >
  • To:
  • Subject: [chef] how do I share common functions between templates
  • Date: Mon, 14 Jan 2013 14:38:21 -0800 (PST)

Hi,

I have a snippet as following and want to share it in mulitiple templates. Is
there a way to do it?

thanks,

Xianfeng

<%
def output_array(s)
    str = ''
    if s.is_a?(Array)
       if s.length >= 1
          str = s.at(0)
          str = "\"#{str}\""
          if s.length > 1
             for i in 1..(s.length - 1)
                 w = s.at(i)
                 str = "#{str}, \"#{w}\""
             end
          end
       end
    end
    "#{str}"
end
%>



Archive powered by MHonArc 2.6.16.

§