Skip to content
Browse files

evalScripts populates variables: _args, _container and _scope

  • Loading branch information...
1 parent 795021d commit 7328fac64cc08ee5b771957e1107c644dc7aa61f @juzna committed Jan 13, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/prototype/lang/string.js
View
10 src/prototype/lang/string.js
@@ -338,7 +338,7 @@ Object.extend(String.prototype, (function() {
}
/**
- * String#evalScripts() -> Array
+ * String#evalScripts([ container, [ scope, ... ]]) -> Array
*
* Evaluates the content of any inline `<script>` block present in the string.
* Returns an array containing the value returned by each script.
@@ -386,7 +386,13 @@ Object.extend(String.prototype, (function() {
* an array containing the value returned by each script.
**/
function evalScripts() {
- return this.extractScripts().map(function(script) { return eval(script) });
+ var _args = $A(arguments); // Arguments for eval scripts
+ return this.extractScripts().map(function(script) {
+ // Get scope and element, or create implicit scope
+ var _container = _args[0], _scope = _args[1];
+ if(_container && (typeof _scope == 'undefined') && typeof window.Scope != 'undefined' && script.match(/_scope/)) _scope = Scope.get(_container);
+ return eval(script);
+ });
}
/** related to: String#unescapeHTML

0 comments on commit 7328fac

Please sign in to comment.
Something went wrong with that request. Please try again.