Hi,

> What works as expected:
>> var from file.txt.erb: <%= var %>

using var instead of @var produces this warning on puppet 3:
*Warning: Variable access via 'var' is deprecated. Use '@var' instead. *

and it's explained here: http://docs.puppetlabs.com/guides/templating.html

*Historically, all of the variables visible in the current scope were also 
available as Ruby methods — that is, fqdn, memoryfree, operatingsystem, 
etc., without the prepended @ sign. This style of reference caused problems 
when variable names collided with Ruby method names; its use emits 
deprecation warnings as of Puppet 3 and will be removed in Puppet 4. Please 
update any existing code which uses it and start any new code out with the 
@fqdn instance-variable syntax.*

> var from file.txt.erb: <%= scope.lookupvar("var") %>
yes, we need to use this function if we need to access 
someothermodule::var, or a hiera variable.
however, using this function for all variables in the current scope would 
be ugly.


> The fact that the member variable syntax @var works at all is confusing,
> and may be considered a bug.

yes. that's what we are saying.

dynamic lookup in templates should show a warning in puppet 2.7, and stop 
working on puppet 3.

Regards,
David


On Sunday, December 1, 2013 11:07:26 AM UTC+1, Felix.Frank wrote:
>
> Hi, 
>
> I've taken a look into the issue and it would appear that your root 
> problem is wrong template syntax. The below is not strictly valid: 
>
> On 11/27/2013 02:40 PM, David Portabella wrote: 
> > file.txt.erb 
> > var from file.txt.erb: <%= @var %> 
>
> What works as expected: 
>
> > var from file.txt.erb: <%= var %> 
>
> or 
>
> > var from file.txt.erb: <%= scope.lookupvar("var") %> 
>
> The fact that the member variable syntax @var works at all is confusing, 
> and may be considered a bug. Will update Redmine accordingly. I believe 
> that the support for such templates should be deprecated if possible. 
>
> Thanks, 
> Felix 
>

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/6e2b0d75-b9d6-4fb9-8823-f102c2ccc81e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to