diff --git a/src/environment.cpp b/src/environment.cpp index e382e7e05..dccda1de8 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -206,6 +206,20 @@ namespace Sass { } }; + // use array access for getter and setter functions + template + T& Environment::get(const std::string& key) + { + auto cur = this; + while (cur) { + if (cur->has_local(key)) { + return cur->get_local(key); + } + cur = cur->parent_; + } + return get_local(key); + } + // use array access for getter and setter functions template T& Environment::operator[](const std::string& key) diff --git a/src/environment.hpp b/src/environment.hpp index a6939be23..a48839aa7 100644 --- a/src/environment.hpp +++ b/src/environment.hpp @@ -7,6 +7,7 @@ namespace Sass { + // this defeats the whole purpose of environment being templatable!! typedef environment_map::iterator EnvIter; class EnvResult { @@ -92,6 +93,10 @@ namespace Sass { // include all scopes available bool has(const std::string& key) const; + // look on the full stack for key + // include all scopes available + T& get(const std::string& key); + // look on the full stack for key // include all scopes available EnvResult find(const std::string& key);