Hi Daniel,

What I've done in the past is:

Foo.erb
<% foobar = scope.lookupvar('::somefact')
  othervar   = scope.lookupvar('class::variable')
lastvar = scope.lookupvar('myclass::myvar')
fqdn = scope.lookupvar('::fqdn')
-%>
#this file generated automatically by puppet for <%=fqdn%>
#manual changes will be reverted


<% if foobar -%>
Foo = <%=foobar%>
<%end-%>
... <stuff and things here > ...


Not sure if there's a better way, but I'm inter the impression (correct me if 
I'm wrong here?) that scope.lookupvar will do the right thing as often as is 
possible.

HtH!

Wolf
MobileMail

> On Jul 1, 2013, at 19:07, Daniel Jung <[email protected]> wrote:
> 
> hi,
> 
> trying to understand the scope for templates -- after reading 
> http://docs.puppetlabs.com/guides/templating.html, got a question about the 
> following,
> 
> 
> class test::foo {
> 
>      file {
>        <snip>
> 
> 
>        content => template ("footemplate.erb"), 
>      }
> 
> }
> 
> 
> class test::foo2 {
>       $var = blah, 
>       class {'test::foo' : 
>       } 
> }
> 
> so the question is if footemplate.erb uses variable $var as @var, is there a 
> need for me to pass it as a argument within class {'test::foo': var => $var ? 
>   My interpretation of templating.html is that all the variables that are in 
> scope of the called class would be passed/available in the template hence i 
> would need to pass it as an argument. 
> 
> Can anyone shed some lights on this?
> 
> Thanks 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to