Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

stdin rendering incorrect #37

Open
hcliff opened this issue Jan 22, 2012 · 1 comment
Open

stdin rendering incorrect #37

hcliff opened this issue Jan 22, 2012 · 1 comment

Comments

@hcliff
Copy link

hcliff commented Jan 22, 2012

version 1.1.0-rc-3

eco -p spling.eco gives this:

(function() {
  this.ecoTemplates || (this.ecoTemplates = {});
  this.ecoTemplates["spling"] = function(__obj) {
    if (!__obj) __obj = {};
    var __out = [], __capture = function(callback) {
      var out = __out, result;
      __out = [];
      callback.call(this);
      result = __out.join('');
      __out = out;
      return __safe(result);
    }, __sanitize = function(value) {
      if (value && value.ecoSafe) {
        return value;
      } else if (typeof value !== 'undefined' && value != null) {
        return __escape(value);
      } else {
        return '';
      }
    }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
    __safe = __obj.safe = function(value) {
      if (value && value.ecoSafe) {
        return value;
      } else {
        if (!(typeof value !== 'undefined' && value != null)) value = '';
        var result = new String(value);
        result.ecoSafe = true;
        return result;
      }
    };
    if (!__escape) {
      __escape = __obj.escape = function(value) {
        return ('' + value)
          .replace(/&/g, '&')
          .replace(/</g, '&lt;')
          .replace(/>/g, '&gt;')
          .replace(/"/g, '&quot;');
      };
    }
    (function() {
      (function() {

        if (model.get("resizeMode")) {
          __out.push('\n<div class="resize"><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div></div>\n');
        }

        __out.push('\n<div class="overlay">\n</div>\n<a href="#"><span>');

        __out.push(__sanitize(model.get("Title")));

        __out.push('</span></a>\n<img src="');

        __out.push(__sanitize(model.get('Image')));

        __out.push('" alt="" />');

      }).call(this);

    }).call(__obj);
    __obj.safe = __objSafe, __obj.escape = __escape;
    return __out.join('');
  };
}).call(this);

however:

eco -s, and then giving the file contents with the stdin gives this:

function(__obj) {
  if (!__obj) __obj = {};
  var __out = [], __capture = function(callback) {
    var out = __out, result;
    __out = [];
    callback.call(this);
    result = __out.join('');
    __out = out;
    return __safe(result);
  }, __sanitize = function(value) {
    if (value && value.ecoSafe) {
      return value;
    } else if (typeof value !== 'undefined' && value != null) {
      return __escape(value);
    } else {
      return '';
    }
  }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  __safe = __obj.safe = function(value) {
    if (value && value.ecoSafe) {
      return value;
    } else {
      if (!(typeof value !== 'undefined' && value != null)) value = '';
      var result = new String(value);
      result.ecoSafe = true;
      return result;
    }
  };
  if (!__escape) {
    __escape = __obj.escape = function(value) {
      return ('' + value)
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;');
    };
  }
  (function() {
    (function() {

      if (model.get("resizeMode")) {
        __out.push('\n<div class="resize"><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div></div>\n');
      }

      __out.push('\n<div class="overlay">\n</div>\n<a href="#"><span>');

      __out.push(__sanitize(model.get("Title")));

      __out.push('</span></a>\n<img src="');

      __out.push(__sanitize(model.get('Image')));

      __out.push('" alt="" />\n');

    }).call(this);

  }).call(__obj);
  __obj.safe = __objSafe, __obj.escape = __escape;
  return __out.join('');
}

(the overall call() is missing)

Not being a node person I have no idea what's causing this. But it stops the latter working in the browser.

Thanks!

@hcliff hcliff closed this as completed Jan 22, 2012
@hcliff hcliff reopened this Jan 22, 2012
@hcliff
Copy link
Author

hcliff commented Jan 22, 2012

So looking around, I'm not sure this is a bug so to speak - It certainly would be useful to have this ability though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant