Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local modifications to variables are not local #43

Open
alem0lars opened this issue Oct 15, 2016 · 0 comments
Open

Local modifications to variables are not local #43

alem0lars opened this issue Oct 15, 2016 · 0 comments

Comments

@alem0lars
Copy link
Owner

alem0lars commented Oct 15, 2016

Expected behavior

When you modify variables inside a local, those modifications should be available only inside the current template.

Actual behavior

The modifications to variables are global, i.e. persisted after processing of the template that modifies the variables is completed.

Steps to reproduce the problem

Reliable way to reproduce the problem:

  1. Create a template foo.tt with:

    <% define_locals do
    variable :"distcc.servers", as: :servers
    computed(:info) do
      local!(:servers).map do |server|
        res = server[:host]
        if server.has_key? :opts
          res << ",#{server[:opts].join(",")}"
        end
        res
      end
    end
    end %>
  2. Create a template bar.tt

  3. When host of servers is accessed inside bar.tt, it shouldn't have the modifications made in foo.tt

Version

Include the output of fizzy version. Here's an example:

$ fizzy version
☞ fizzy version 2.2.0
☞ ruby version ruby 2.4.0p-1

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38399944-local-modifications-to-variables-are-not-local?utm_campaign=plugin&utm_content=tracker%2F10471801&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10471801&utm_medium=issues&utm_source=github).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant