title: how to test the result of applying a puppet template to given test parameters
body: <p>I have the following puppet template file solr.json.erb:</p>
  
  <pre><code>{
    "servers" : [ {
      "port" : "&lt;%= jmx_port %&gt;",
      "host" : "localhost",
  
      "queries" : [
        &lt;% @markets.each do |market| -%&gt;
      {
        "outputWriters" : [ {
          "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        } ],
        "obj" : "solr/market_&lt;%= market %&gt;:type=queryResultCache,id=org.apache.solr.search.LRUCache",
        "attr" : [ "hits","hitratio"]
      },
      &lt;% end -%&gt;
      ],
      "numQueryThreads" : 2
    } ]
  }
  </code></pre>
  
  <p>and I want to test the result of applying the template to some test parameters before executing this in puppet.</p>
  
  <p>how can I do that?</p>
  
  <p>before, I tried with a script like this, my_script.ruby</p>
  
  <pre><code>require 'erb'
  require 'ostruct'
  namespace = OpenStruct.new(:jmx_port =&gt; 9200, :markets=&gt; ['CH', 'FR'])
  template = File.open("solr.json.erb", "rb").read;
  puts ERB.new(template).result(namespace.instance_eval { binding })
  </code></pre>
  
  <p>but it didn't work out, because OpenStruct does not have <code>instance variables</code>, so I cannot use <code>@markets</code>.</p>
  
  <p>the documentation mentions that you can check the syntax with this command:
  <a href="http://docs.puppetlabs.com/guides/templating.html" rel="nofollow">http://docs.puppetlabs.com/guides/templating.html</a></p>
  
  <pre><code>erb -P -x -T '-' mytemplate.erb | ruby -c
  </code></pre>
  
  <p>but that's not what i am asking.
  i am asking to get the result of applying some test parameters (jmx_port=9200, markets=['CH', 'FR']) to the template.</p>
  
  <p>how can I do that?</p>