Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Don't use eval for dictionary access. #22

merged 1 commit into from

2 participants

Jakub Korál Vadim Baryshev
Jakub Korál

Eval is not needed here

Vadim Baryshev

This eval uses to get access to nested objects. For example:

  news : {
    list : '<ul>...</ul>',
    element : '<p>...</p>'
  items : {
    list : '<ul>...</ul>',
    element : '<p>...</p>'

With this eval we can access this templates by 'news.list' or 'items.element', without eval we can't do it.

Jakub Korál

Is it ok now?

I'd like to get avoid of the eval here, just because the root can be much much larger than I want to evaluate.

Vadim Baryshev baryshev merged commit 41cd25e into from
Vadim Baryshev

0.4.11 published. Also i added Array.reduce compatibility function for old browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2013
  1. Jakub Korál
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/ect.js
2  lib/ect.js
@@ -54,7 +54,7 @@
read = function (file) {
if ( === '[object Object]') {
- var data = eval('(ect.options.root.' + file + ')');
+ var data = file.split('.').reduce(function (currentContext, key) { return currentContext[key]; }, ect.options.root);
if ( === '[object String]') {
return data;
} else {
Something went wrong with that request. Please try again.